Proceed to GeoCommunity Home Page


SpatialNewsGIS Data DepotGeoImaging ChannelGIS and MappingSoftwareGIS JobsGeoBids-RFPsGeoCommunity MarketplaceGIS Event Listings
HomeLoginAccountsAboutContactAdvertiseSearchFAQsForumsCartFree Newsletter

Sponsored by:


TOPICS
Today's News

Submit News

Feature Articles

Product Reviews

Education

News Affiliates

Discussions

Newsletters

Email Lists

Polls

Editor's Corner


SpatialNews Daily Newswire!
Subscribe now!

Latest Industry Headlines
SiteVision GIS Partnership With City of Roanoke VA Goes Live
Garmin® Introduces Delta™ Upland Remote Trainer with Beeper
Caliper Offers Updated Chile Data for Use with Maptitude 2013
Southampton’s Go! Rhinos Trail Mapped by Ordnance Survey
New Approach to Measuring Coral Growth Offers Valuable Tool for Reef Managers
Topo ly - Tailor-Fit for Companies' Online Mapping Needs

Latest GeoBids-RFPs
Nautical Charts*Poland
Software & Telemetry GPS
Spatial Data Management-DC
Geospatial and Mapping-DC
Next-Gen 911-MO

Recent Job Opportunities
Planner/GIS Specialist
Team Leader- Grape Supply Systems
Geospatial Developer

Recent Discussions
Raster images
cartographic symbology
Telephone Exchange areas in Europe
Problem showcasing Vector map on Windows CE device
Base map

GeoCommunity Mailing List
 
Mailing List Archives

Subject: [gislist] Obtaining an based on x/y coordinate pair
Date:  03/22/2004 08:15:00 AM
From:  iheanyi Okeh



This is a repost since I inadvertently omitted title on my first post


I have been trying desperately but unsuccessfully to get the address closest
to the x/y coordinate pair.

A user enters x/y coordinate pair say x=0234.22 and y=236541.21

Based on the x/y coordinate pair, I will like to return the closest address


The table structure looks like this:

str_num , --street number
str_name, -- street name

the_geom -- contains x/y coordinate values

As you know, in PostGIS we get the x and y of each point shape using the
x(geometry) and y(geometry) functions.
However, in our database, the geometry is already in the field called
the_geom, so to get the x and y for each point we use it like this:
x(the_geom) and y(the_geom).

The code I am using so far isn't working.
Infact, it always returns the same address, no matter what the x/y
coordinate pair is.

Here is that code:


select
sqrt(distance) AS distance,
str_num || ' ' || name AS address
from
(select (x(the_geom) - x(the_geom))^2 + (y(the_geom) - y(the_geom))^2 as
distance, *
from address order by distance limit 1) as r


It is important to point out that if I use a where predicate, such as this:

select
sqrt(distance) AS distance,
str_num || ' ' || name AS address
from
(select (x(the_geom) - x(the_geom))^2 + (y(the_geom) - y(the_geom))^2 as
distance, *
from address where x(the_geom) = someXValue and y(the_geom) = someYValue
ORDER BY distance limit 1) as r

the code stops returning any values at all.
Any help would be truly appreciated.

I have heard terms such as bounding box, contains and intersections but I am
extremely new to postgreSQL/postGIS and wouldn't know how to use them in
this case.
Many thanks in advance

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE
download! http://clk.atdmt.com/AVE/go/onm00200413ave/direct/01/

_______________________________________________
gislist mailing list
gislist@lists.geocomm.com
http://lists.geocomm.com/mailman/listinfo/gislist

_________________________________
This list is brought to you by
The GeoCommunity
http://www.geocomm.com/

Get Access to the latest GIS & Geospatial Industry RFPs and bids
http://www.geobids.com

Sponsored by:

For information
regarding
advertising rates
Click Here!

Copyright© 1995-2012 MindSites Group / Privacy Policy

GeoCommunity™, Wireless Developer Network™, GIS Data Depot®, and Spatial News™
including all logos and other service marks
are registered trademarks and trade communities of
MindSites Group