![]() ![]() ![]() Re: advice needed: efficient approach to find stre...
| ujaval@gmail.co... | 07-16-2007 |
If you were Registered and logged in, you could reply and use other advanced thread options
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).
I process that file and try to find those streets that are close to a
given point. So what I do is 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).
Do you have any ideas how to speed up the process of finding the
nearest street(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 could be quite near.
Any help is appreciated!
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).
I process that file and try to find those streets that are close to a
given point. So what I do is 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).
Do you have any ideas how to speed up the process of finding the
nearest street(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 could be quite near.
Any help is appreciated!
Pre-process the data and create a spatial index. Then you will be able to do
the spatial searches a lot faster. But that requires either writing lots of
code or using other software - any capable GIS should be able to do this.
Regards
Uffe Kousgaard
> > Do you have any ideas how to speed up the process of finding the
> > nearest street(s)?
> > nearest street(s)?
> Pre-process the data and create a spatial index. Then you will be able to do
> the spatial searches a lot faster. But that requires either writing lots of
> code or using other software - any capable GIS should be able to do this.
> the spatial searches a lot faster. But that requires either writing lots of
> code or using other software - any capable GIS should be able to do this.
Unfortunately I have to use php to do this, as I'm interacting with
google maps. I'm afraid its out of my scope to write a spatial
database in php ;-)
Thanks for the help anyway.
Anybody any idea on how to generally speed up the process without a
spatial database?
> > > Do you have any ideas how to speed up the process of finding the
> > > nearest street(s)?
> > > nearest street(s)?
> > Pre-process the data and create a spatial index. Then you will be able to do
> > the spatial searches a lot faster. But that requires either writing lots of
> > code or using other software - any capable GIS should be able to do this.
> > the spatial searches a lot faster. But that requires either writing lots of
> > code or using other software - any capable GIS should be able to do this.
> Unfortunately I have to use php to do this, as I'm interacting with
> google maps. I'm afraid its out of my scope to write a spatial
> database in php ;-)
> Thanks for the help anyway.
> Anybody any idea on how to generally speed up the process without a
> spatial database?
> google maps. I'm afraid its out of my scope to write a spatial
> database in php ;-)
> Thanks for the help anyway.
> Anybody any idea on how to generally speed up the process without a
> spatial database?
I am not sure why you can't use a spatial database. You don't have to
write one, just use the php interface to access the database.
Postgresql should suffice your requirements for building spatial index
and I have used to it with php to build google maps applications.
-Ujaval
http://spatialthoughts.com
> I am not sure why you can't use a spatial database. You don't have to
> write one, just use the php interface to access the database.
> Postgresql should suffice your requirements for building spatial index
> and I have used to it with php to build google maps applications.
> write one, just use the php interface to access the database.
> Postgresql should suffice your requirements for building spatial index
> and I have used to it with php to build google maps applications.
Well, I'm using mysql as the database and it spatial database parts
lacks the distance-function, which I need most. I didn't know that
postgresql has this extension already. I now use the serialize
function to store and load some preprocessed (i.e. stripped) data. Its
not a professional solution, but it works for now and does not need a
database, which is a bit pro for local deployment. But thank you for
the hint towards postgresql, I will keep it in mind.







> nearest street(s)?