[postgis-users] Nearest Operator
Gregory S. Williamson
gsw at globexplorer.com
Thu May 8 22:17:01 PDT 2003
FWIW, the IBM/Informix spatial blade also has a nearest function SE_nearest. Given two arguments (a geometry column name with an R-tree index on it and a geometry in the same SRID) it returns results in increasing distance from the geometry. It has a variant using the distance between the objects' bounding boxes ("a simpler calculation ... executes more quickly, but may return objects in a different order depending on the actual shape of the objects.")
It is dependent on some underlying functionality in the database engine itself in the more recent versions. Quite a useful beast although it can be improvised using a distance function and a temp table (slower of course).
Greg Williamson (a lurker, usually)
DBA, GlobeXplorer LLC
-----Original Message-----
From: Roy Irwan [mailto:mroy at centrin.net.id]
Sent: Thu 5/8/2003 8:36 PM
To: PostGIS Users Discussion
Cc:
Subject: Re: [postgis-users] Nearest Operator
----- Original Message -----
From: <chodgson at ref...>
Sent: Thursday, May 08, 2003 11:15 PM
> I am not very familiar with Oracle spatial, could you tell me exactly what
the
> parameters and output of the this "nearest" function are?
In Oracle Spatial, we can find the nearest neighbors for a geometry using
SDO_NN operator. It has 4 input params.
The 1st param is the geometry column in a table. The nearest neighbor(s)
will
be return from this column.
The 2nd param is a geometry that can take from a table or a transient
instance of a geometry.
The 3rd param determines the behavior of the operator, like how many geoms
you expect as the result, unit of measurement and how many rows to be
evaluated at a time.
The 4th param is an optional. This param is used if you would like to return
the distance for each neighbor.
Because this is an operator, we only can use it under WHERE condition an
compare it with string 'TRUE'.
For example:
SELECT c.mkt_id, c.name
FROM cola_markets c
WHERE SDO_NN(c.shape, mdsys.sdo_geometry(2001, NULL,
mdsys.sdo_point_type(10,7,NULL), NULL,
NULL), ’sdo_num_res=2’) = ’TRUE’;
I took the example from Oracle Spatial User's Guide and Ref ver 9.2.
> I guess the simplest
> answer to your question would be: "Is the 'nearest' operator in the OGC
SFSQL
> spec?" - if it is, then it will almost certainly be implemented this
summer,
> because the primary goal right now for PostGIS is to reach SFSQL
compliance.
I've been quick review the OGC SFS for SQL rev. 1.1, unfortunately there is
no 'nearest' operator. :(
> If it is not in the spec, then I would suggest that you could try to
implement it
> yourself, I'm sure we would include such a function in the distribution,
> if you sent it to us.
Wish I could do that. Unfortunately, I'm not too familiar with Linux env
development. And I'm a new comer in PostgreSQL + PostGIS world. So, this is
could be a long road for me. However, I'll try to do my best (not a
promise). :)
> Later,
> Chris
Rgds,
Roy
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list