We have customer's (customer name , latitude , longitude ). Is there any function in postgress where we can pass extent (Rectangle extent ) and it filter customer based on extent (customer lies in rectangle extent). we don't want iterate all customer and check whether customer exists in given extent.
Related
I am trying to prepare a Overpass QL such a way that it iterate through a list of City Names and find sum of lengths of all the road centerline features which are falling inside the city administrative boundary.
The idea is not to download to entire data rather to get only required total road length per city wise.
New York City, New York, USA
Toronto, Ontario, Canada
Jersey city, New Jersey, USA
<City_Name>, <STATE/PROVINCE>,
Above is the example input and below is sample QL with BBOX but need to automate either with overpy python api or writing single overpass QL for entire list of cities.
[out:json][timeout:25];(way"highway"="primary";way"highway"="secondary";way"highway"="tertiary";way"highway"="unclassified";way"highway"="residential";);(._;>;);out;
Appreciate if someone can give pointers to move ahead.
-Prem
I am working on a project where I need to get a shapefile of all roads in a given US county from open streetmap data, add some information to the county roads, then merge the individual county road shape files into a larger single shapefile using qgis.
My current process is to download the state roads map from the OSM repsitory that has my desired counties, and clip the larger state map to my desired county set of roads using qgis. I use the census bureau's county boundary shapefile to determine the boundary of the clip. The problem is that qgis seems to delete small sections of roads at the county boundary and I am unable to merge the "fabric" of the map together because there are gaps in road lines at the county boundary.
As an alternative approach, I have stared to research using the OSM overpass api to query for a set of county roads. If I can query OSM for all roads within a given county and download as a shapefile, should I then be able to merge the individual county road maps into a larger map without gaps and avoid the problem I have with clipping?
Are there any articles that describe the overpass api query for getting roads within a known administrative boundary, like a US county?
Is there anyway, using MapKit, to check if a user is in a building, at a certain address?
I have the users current position (longitude, latitude):
I have a buildings address - for example, 298 Texas St, San Francisco.
Is there anyway I could tell if a user is at that address / in the building?
I have tried converting coordinates into an address, and just checking the address against the other one, however, my problem is that if the address is a house, and the user walks past it, it will return true, when, in reality, it is not.
Thanks for the help!
Addresses are usually reported as "geo-points", which is just a single lat/long coordinate. Without more information, you know nothing about the size or shape of the dwelling that represents the address.
Also, addresses are sometimes entered into mapping databases by interpolating between a starting address/coordinate and and ending address/coordinate. If the houses aren't evenly spaced, the coordinates of a given address can be wrong.
Plus, GPS's are pretty unreliable indoors, especially in office buildings and multi unit dwellings.
As a result, the short answer to your question is no.
You could ask the location manager for lat/long coordinates of the address, and then use another location manager call to get the distance from the user's current location, and use a distance value (20 meters?) to decide that the user is "at that address". That's likely the best you're going to be able to do.
I have a question about the use of postgreSQL/postGIS.
I would like to display markers on a map (stored in a database) which are some distance away from the user (coordinates given to the request).
The type of the field of the markers is POINT (I store lat/long).
The user position is detetermined by the Google Map API.
Here is the actual request :
SELECT * FROM geo_points WHERE ST_distance(ST_SetSRID(geo_points.coords::geometry,4326),ST_GeomFromEWKT('SRID=4326;POINT(45.0653944 4.859764599999996)')) > 65
I know (after some research on internet) that the function ST_distance gives me the distance in degree between markers and the user position and that I test the distance in km.
I think I have to use the function ST_tranform to transform the points in metric coordinates.
So my questions are :
- what is the SRID for France
- how can I make this dynamically for the entire world according to the user position ?
I also kow that the function ST_within exists and that could do this. But I anticipate the fact that later, I could need the distance.
Any help would be greatly appreciated
ps: there are maybe solutions in other post, but all the answers I have found during my researches were not really meeting my needs.
Firstly, pay attention to the axis order of coordinates used by PostGIS, it should be long/lat. Currently you are searching in Somalia. Swapping to the coordinates, you would be searching in France.
You can use a geodesic calculation with the geography type, or use geodesic functions like ST_Distance_Spheroid. With the geography type, you may want to use ST_DWithin for higher performance.
Here are geo_points 65 m away or less from the point of interest in France (not Somalia):
SELECT * FROM geo_points
WHERE ST_Distance_Spheroid(
ST_Transform(geo_points.coords::geometry, 4326),
ST_SetSRID(ST_MakePoint(4.859764599999996, 45.0653944), 4326),
'SPHEROID["WGS 84",6378137,298.257223563]') < 65.0;
However, it will be very slow, since it needs to find the distance to every geo_points, so only do this if you don't care about performance and have less than a few thousand points.
If you change and transform geo_points.coords to store lon/lat (WGS84) as a geography type:
SELECT * FROM geo_points
WHERE ST_DWithin(
geo_points::geography,
ST_SetSRID(ST_MakePoint(4.859764599999996, 45.0653944), 4326)::geography,
65.0);
Given is a DB full of parent/child relationships of political district geo data/names:
Country
State
District
Now I'm querying for that data, building a string like germany,bavaria,ebersberg and then I try to fetch the lat/lng center of that district via the Nominatim API (part of OpenStreetMaps).
Example String:
http://nominatim.openstreetmap.org/search?format=xml&polygon=0&addressdetails=0&q=germany,bavaria,ebersberg
Problem is, that I get back a bunch of POIs with lat/lng instead exact geographical data. This often results in having exact the half of that district displayed as the first POI could be close to that districts border.
Does anyone know of a way to get the lat/lng of the center or how to center a OSM map? OR does anyone know of an alternate API that can achieve this and tell how it works/make an example?
Does anyone know of a way to get the lat/lng of the center or how to center a OSM map?
When you get a bunch (list, set) of points of interest with latitudes and longitudes, you have a feature, not a problem.
You iterate through the POI, building a bounding rectangle that includes all of the POI. In other words, you find the minimum latitude, minimum longitude, maximum latitude, and maximum longitude.
You find the center of the rectangle by the formula
(maximum + minimum) / 2
The bounding area should be small enough that you're not going to incur much error working with latitude and longitude.
Otherwise, you can calculate the distance between the minimum latitude, longitude and the maximum latitude, longitude. The center is half the distance from the minimum latitude, longitude. Convert that center point back to a latitude and longitude for your answer.