|  | Posted by busnet on 07/12/07 11:50 
Hi.I've got the following problem: I have a huge xml-file that represents
 a street map of a city. Each street is stored as a couple of
 coordinates (start, end and all the turns).
 When I set a marker in a google map, I want to find all streets that
 are near this marker position.
 I now parse the whole file as a simpleXML object, and calculate the
 distances to each street segment (using linear algebra algorithms,
 that is, constructing the vector from two points and computing the
 distance from the given point to this vector).
 Up to now it works like this: I set a marker and the gmaps method
 "gdownload()" calls a server side php script, which
 1. reads the xml file into an simplexml object
 2. for every two coordinates that belong to the same street, it
 calculates the vector and computes its distance to the point
 3. returns the nearest x streets (as polylines) back to the client
 
 It repeats this, when I set the next marker.
 
 Problems/need for ideas:
 1) It always reads the XML file anew, when I set another marker. Is
 there some way to cache this or a more intelligent approach? I tried
 saving the whole Simplexml-object in a session variable, but it was
 too huge. I guess I could create some tables in mysql, but I'm not
 sure thats the best solution yet.
 2) Not php-specific: Do you have any ideas how to speed up the process
 of finding the nearest lane(s)? I tried to consider only those streets
 whose endpoints are within a certain range from the given marker-
 point, but it was not considerably faster and if there was a street
 thats very long and straight the endpoints may be far away, but the
 street itself is quite near.
 [Back to original message] |