Here's my problem: a smartphone will send to my server some gps coordinates (latitude,longitude,altitude) and I'll have to compare these to an address stored in db in order to see how much distance there is between smartphone and address.
I'll need to obtain this address coordinates as well in order to do the actual comparison.
Is there a good and easy to use gps library for java?Any suggestions?
In your answers please note that I need a way to get coordinates from an address too!! So, given an address "second street 2,New York, zip code 01245", I need to find latitude,longitude,altitude,ecc.
Android's Location class has a static method distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results). You can look at the source code and use it in your program.
You could take a look at
A distance calculator using GeoCodes
Distance between 2 geocodes
Related
I am working with a SIM868 cellular modem with GPS capabilities. I have access to send and receive data from/to the GPS processor, a MediaTek MT2503DV.
When I look at the raw data coming out of the processor, I see numerous NMEA strings ($GPGGA, $GPRMC...), and also $GPACCURACY. I cant find any documentation on $GPACCURACY, but I presume it is a number in meters of the accuracy of the GPS.
The $GPACCURACY string looks like this $GPACCURACY,25.9*36
What is $GPACCURACY, and what do the numbers following it mean?
Is there a way to only receive this and $RMC data out of the GPS?
From the 868 manual:
Message ID GPACCURACY:ACCURACY OF THE LOCATION
This message is accuracy of the location; The smaller the number is, the be better the condition is;
Table 2-11: GPACCURACY Data Format
Example: $GPACCURACY,961.2*04
Link to manual:
http://simcom.ee/documents/SIM868/SIM868_NMEA%20Message%20Specification_V1.03.pdf
I have a SIM900 and Arduino Leonardo. using the SIM900.h library I have it all working and receiving text messages, etc however I'm wondering how I can use it to either grab all the local tower information or grab the same and triangulate the LAT, LONG, ETC from that information.
You can get information about the local tower (and for a few neighboring towers) with the AT+CENG=2 command. This include things like tower ID and signal level. You'll need to know the geographic location of these towers and do the triangulation yourself.
I suggest you take a look at this project: http://www.open-electronics.org/mini-gsm-localizer-without-gps/. It has an open-source firmware that you may find useful.
Here’s sequence of AT commands needed to get location of module:
AT+SAPBR=3,1,"CONTYPE","GPRS" // set bearer parameter
OK
AT+SAPBR=3,1,"APN","internet" // set apn
OK
AT+SAPBR=1,1 // activate bearer context
OK
AT+SAPBR=2,1 // get context ip address
+SAPBR: 1,1,"10.151.43.104"
OK
AT+CIPGSMLOC=1,1 // triangulate
+CIPGSMLOC: 0,19.667806,49.978185,2014/03/20,14:12:27
OK
Location is not acurrate though, first test got me coordinates located around 4 kilometers away from my place. Usually it’s not that bad, enough for simple applications.
you can use AT+COPS? command to reach location of tower. the 4-digit number expresses the location. for decode the number yıu should use LAC.
i.e +CGREG: 1, A9F0, 200D6E
(the second term A9F0 is the location number of tower)
I need Lat/LON from GIS data
I have data files from
http://www.mngeo.state.mn.us/chouse/land_own_property.html
given in the format of
.dbf, .prj, .sbn, .sbx, .shp, and .shx
in the .dbf I see
PIN, Shape_area, Shape_len
PARC_CODE Parcel Polygon to Parcel Point numeric 2
and PIN Relationship Code
and in the .prj
PROJCS["NAD_1983_UTM_Zone_15N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-93.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
I also know the polygon points for each county
polygons points
Anoka 129139 129138
Carver 38134 38133
Dakota 135925 150294
Hennepin 422976 446623
Ramsey 149169 168233
Scott 55191 55191
Washington 98915 103915
and I know the bounding coordinates
-94.012
-92.732
45.415
44.471
there seems to be tons of software applications for GIS
http://en.wikipedia.org/wiki/List_of_geographic_information_systems_software
but what do I need to do?
I want the lat, lon of every house
Is there a library that will do this for me?
What is the data I need?
I think you need to install one GIS software. You can try open-source Qgis.
Because, firstly your data is not in long/lat (geographic) coordinates. Your .prj part of the shapefile (yes, all .dbf, .prj, .sbn, .sbx, .shp, and .shx files with the same name are one shapefile for GIS) says that the data are in the projected coordinate system NAD 1983 UTM Zone 15N. So, you need to transform your data to geographic system. This you easy can do in GIS, or programmatically by proj.4 library. (In Qgis add the shapefile to the project, then select it in the table of contents, right mouse button and choose "save as...". It will ask you for the target coordinate system.) Note, that you need to decide which geographic coordinates you wish, because your data are in the North American Datum (NAD 1983), but the most common worldwide now is WGS 1984.
Secondly, in GIS you will see your data, are they really points, or maybe polygons. (In case your houses are polygons you will need to get centroids of them, in Qgis menu Vector - Geometry Tools - Polygon Centroids).
Finally, when you really have your houses as points in geographic coordinates, you can get their coordinates, for example using advices from these questions Get list of coordinates for points in a layer and How do I calculate the latitude and longitude of points using QGIS.
Besides, there is a good library to work with GIS vector data, OGR, which can be used by many programming languages.
The file extensions above show, that the files are in ESRI Shape File format. In Java you could use GeoTools libraries, to read that.
The example below shows the first lines, search Internet for a more complete example.
// init shapefile
File shpFile = new File(fileName);
if (!shpFile.exists()) {
LOGGER.fatal(fileName + " does not exist");
}
Map<String, URL> connect = new HashMap<String, URL>();
FeatureCollection collection = null;
FeatureIterator iterator = null;
try {
connect.put("url", shpFile.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(connect);
String typeName = dataStore.getTypeNames()[0];
"I want the lat, lon of every house" suggests that what you want to do is the process called geocoding. There are services you can use for that, some free (for limited uses) some not. You could start by looking at the List of geocoding systems to get an idea of where to start. I don't think you want to start by learning GIS or shapefiles, other than to extract the addresses you are trying to geocode.
You could estimate the lat/lon of each house by computing the centroid of each parcel. You could more roughly estimate the lat/lon of each house by calculating the centroid of the bounding rectangle of each parcel. Either of those would require extracting the parcel coordinates. If you are doing that for every house in Minnesota you will processing lots of data. A geocoding service would be cheaper. The Census Geocoder might help.
Google sometimes returns the incorrect U.S. state when reverse geocoding a lat/long. Presumably this is because Google is trying to return the nearest street address, which in some cases is not in the same state as the lat/long you are trying to reverse geocode.
Though it may not be a common scenario in practice, it's pretty easy to reproduce by playing around with a map: http://gmaps-samples.googlecode.com/svn/trunk/geocoder/reverse.html
For my application, I am less concerned about getting the nearest address and more concerned about always getting the correct U.S. state for a lat/long. Is there a way to achieve this with Google's API?
Thank you
Iterate over all results and pick the one with "administrative_area_level_1" in results[i].types
This is better than taking the "equivalent" address component from the first result, i.e. finding "administrative_area_level_1" in results[0].address_components[j].types
When reverse geocoding snaps your latlng to the nearest address which happens to be in a different state (or country), the state/country address component of the first result will be that of where that address is, but the subsequent result will be the state/country where the input latlng is.
Example: 42.834185,-0.302811 is in Spain, but snaps to an address in France.
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D42.834185%252C-0.302811
results[0].address_components[3].types = ["administrative_area_level_1", "political"]
results[0].address_components[3].short_name = "FR"
results[6].types = ["administrative_area_level_1", "political"]
results[6].short_name = "ES"
I want using GPS data (I got it from $GPRMC) in an desktop application(that uses from mappoint 2009). I get the latitude & longitude, but when I check these points on map, I see the result is incorrect (for example My Data is: 43.412 N, 79.369 W ; but the correct point is: 43.686 N, 79.616 W ).
I guess, I must use a correction method before use; I try "Projection method" like "Miller" or "Mercator", but those aren't effective.
Can anyone guide me?
Are you using the same coordinate systems? E.g. WGS-84 or something else?