title: Multi-location entity query solution with geographic distance calculation
body: <p>in my project we have an entity called Trip. This trip has two points: start and finish. Start and finish are geo coordinates with some added properties like address atc.</p>
  
  <p>what i need is to query for all Trips that satisifies search criteria for both start and finish.</p>
  
  <p>smth like</p>
  
  <pre><code>select from trips where start near 16,16 and finish near 18,20 where type = type
  </code></pre>
  
  <p>So my question is: which database can offer such functionality?</p>
  
  <p><strong>what i have tried</strong></p>
  
  <p>i have explored mongodb which has support for geo indexes but does not support this use case. current solution stores the points as separate documents which have a reference to a Trip. we run two separate quesries for starts and finishes, then extract ids of their associated trips and then select trip ids that are found both in starts and finishes and finally return a collection of trips.</p>
  
  <p>on a small sample it works fine but with a larger collection it gets slow and it's like scratching my left ear with my right hand.</p>
  
  <p>so i am looking for a better solution.</p>
  
  <p>i know about neo4j and its spatial plugin but i couldn't even make it work on windows. would it support our use case?</p>
  
  <p>or are there any better solutions? preferably with a object mapper written in php.</p>