I'm having a hard time understanding how to see on a map the location given to me by some location NMEA sentence:
foe example: given the sentence
$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
where and what information do I type, to see this location on a map?
It is in ddmm.mmmm format for latitude and in dddmm.mmmm for longitude
to convert it into dd.dddd format you will need to do
dd + mm.mmmm/60 for latitude
ddd + mm.mmmm/60 for longitude
in your case
4916.45,N,12311.12,W
will be
49 + (16.45/60) = 49.2741 N
123 + (11.12/60) = 123.1853 W
simply put (49.2741 N 123.1853 W) on google maps to see the location
go to this website:
https://www.gpsvisualizer.com
click on "Plot data points"
Now you will see text box. copy your NMEA strings there. it will display the positions on the map
just put those params into
http://www.findlatitudeandlongitude.com/
Related
Im using the last version of datastax dse graph. I need to load geo point from text file into the graph.
Is it ok to write POINT(12.3 34.5) for geo point in the text data file?
or POINT(X,Y)? or Geo.point(x,y)?
There is an example in the documentation that shows how to load geo data - https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/reference/refDSEGraphDataTypes.html?hl=graph,geo,data
graph.addVertex(label,'author','name','Jamie Oliver','gender','M','point',Geo.point(1,2))
you can convert the longitude and latitude values into a Point using a transform with DSE GraphLoader (https://docs.datastax.com/en/datastax_enterprise/latest/datastax_enterprise/graph/dgl/dglTransform.html)
geoPointInput = geoPointInput.transform { it['location'] = new com.datastax.driver.dse.geometry.Point(Double.parseDouble(it['longitude']),Double.parseDouble(it['latitude'])); it }
I am working on an assignment where I need to draw a line between points on a map. I built it up using if statements, but that limits how many times I can do something so want to use a loop.
The code I have so far is below, I can add the cities and draw a line, but it draws a line to itself rather than from a start point to the next point (and continue on)
Can anybody please help at all?
def level1():
cityXvalue = [45,95,182,207,256,312,328,350,374,400]
cityYvalue = [310,147,84,201,337,375,434,348,335,265]
# Display the map image
map = makePicture(getMediaPath("map.png"))
show(map)
number = 0
# Ask user to enter numbers of the cities they wish to visit
cities = requestInteger("Enter the number of the city you would like to visit")
# Draw a line between previously entered point and current one
while cities > number:
city = requestInteger("Please choose a city number")
addLine(map,cityXvalue[city],cityYvalue[city], cityXvalue[city], cityYvalue[city])
repaint(map)
Good day, friends!
Sorry, if i wrote it too complex... thank you for the help.
I have an event (with some options) that starts in one location and ends in other location (other city).
Database: mySQL
Structure:
locations: id, address, lat, lng
events: id, title,start_loc_id, end_loc_id, some other options (like rating).
events.start_loc_id, events.end_loc_id - Foreign key to locations.id
Locations from: https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql
So the problem:
Need to search an event with (for example)
100 km radius around start location
80 km around end location
Rating > 10
So to look around location I using: https://gist.github.com/goosechaser/07dbf28818cedc1c9bb5
(btw: PHP framewok: Laravel)
How it goes now:
We found 24 locations for start
We found 33 locations for end
Then "WHERE IN" arrays to event's start and end location.
Laravel code:
$Events = Events::whereIn(
'start_loc_id',
Location::distance(
Input::get('start_location_lat'),
Input::get('start_location_lng'),
Input::get('start_location_radius'),
"km")
->orderBy("distance")->lists('id'))
->whereIn(
'end_loc_id',
Location::distance(
Input::get('end_location_lat'),
Input::get('end_location_lng'),
Input::get('end_location_radius'),
"km")
->orderBy("distance")->lists('id'))
->get();
So what if we have 1000 locations found? Obviously will work too slow.
What is the better way to do it with php/mysql?
Temporary table?
Switch to elasticsearch?
Add start_location_lat, start_location_lng and end_location_lat, end_location_lng to events table?
Thank you for the help!
I recommend using an indexation method like MongoDB's geospatial commands http://docs.mongodb.org/manual/reference/command/nav-geospatial/, I think elasticsearch can do too http://www.elasticsearch.org/blog/geo-location-and-search/
I am using an API (link for sample data can be found HERE) The way I have it now, using urlread, it reads all that data into one cell. How do I make it read into multiple cells? The ultimate goal is to extract the location_name, so if you could help me with that too thatd be great!
The sample data is provided as JSON, so you want a JSON parser, for example this one.
You use it like this:
>> url = 'http://www3.septa.org/hackathon/locations/get_locations.php?lon=-75.1903105&lat=39.9601978&type=rail_stations&radius=5';
>> contents = urlread(url);
>> data = parse_json(contents);
>> data = data{1}; # For some reason it returns a cell array with one element...
>> data{1}
ans =
location_id: 90004
location_name: '30th Street Station'
location_lat: '39.9566667'
location_lon: '-75.1816667'
distance: '0.5184'
location_type: 'rail_stations'
location_data: [1x1 struct]
I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post.
I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below
I would really like something that is fairly genetic so if the file layout changes it won't mess me around to much. At the moment I am just reading the file in a line at a time and just using a case statement to check which section i'm in.
Is anyone able to help me with this?
PS. I am using VB but C# or anything else will be fine, also the x's in the document are just personal info I have blanked
Thanks,
Nathan
File:--->
DIAL BEFORE YOU DIG
Call 1100, Fax 1300 652 077
PO Box 7710 MELBOURNE, VIC 8004
Utilities are requested to respond within 2 working days and reference the Sequence number.
[REFFERAL DETAILS]
FROM= Dial Before You Dig - Web
TO= Technical Services
UTILITY ID= xxxxxx
COMPANY= {Company Name}
ENQUIRY DATE= 02/10/2008 13:53
COMMENCEMENT DATE= 06/10/2008
SEQUENCE NO= xxxxxxxxx
PLANNING= No
[CALLER DETAILS]
CUSTOMER ID= 403552
CONTACT NAME= {Name of Contact}
CONTACT HOURS= 0
COMPANY= Underground Utility Locating
ADDRESS= {Address}
SUBURB= {Suburb}
STATE= {State}
POSTCODE= 4350
TELEPHONE= xxxxxxxxxx
MOBILE= xxxxxxxxxx
FAX TYPE= Private
FAX NUMBER= xxxxxxxxxx
PUBLIC ADDRESS= xxxxxxxxxx
PUBLIC TELEPHONE=
EMAIL ADDRESS= {Email Address}
[LOCATION DETAILS]
ADDRESS= {Location Address}
SUBURB= {Location Suburb}
STATE= xxx
POSTCODE= xxx
DEPOSITED PLAN NO= 0
SECTION & HUNDRED NO= 0
PROPERTY PHONE NO=
SIDE OF STREET= B
INTERSECTION= xxxxxx
DISTANCE= 0-200m B
ACTIVITY CODE= 15
ACTIVITY DESCRIPTION= xxxxxxxxxxxxxxxxxx
MAP TYPE= StateGrid
MAP REF= Q851_63
MAP PAGE=
MAP GRID 1=
MAP GRID 2=
MAP GRID 3=
MAP GRID 4=
MAP GRID 5=
GPS X COORD=
GPS Y COORD=
PRIVATE/ROAD/BOTH= B
TRAFFIC AFFECTED= No
NOTIFICATION NO= 3082321
MESSAGE= entire intersection of Allora-Clifton rd , Hillside
rd and merivale st
MOCSMESSAGE= Digsafe generated referral
Notice: Please DO NOT REPLY TO THIS EMAIL as it has been automatically generated and replies are not monitored. Should you wish to advise Dial Before You Dig of any issues with this enquiry, please Call 1100
(See attached file: 3082321_LLGDA94.GML)
Google has the answers, once you know that the file-format is called '.ini'
Edit: That is, it's an .ini plus some extra leading/trailing gunk.
You could read each line of the file sequentially. Each line is essentially a name value pair. Place each value in a map (hash table) keyed by name. Use a map for each section. When done parsing the file you'll have maps containing all the name value pairs. Iterate over each map and populate your database tables.
I would head to Python for any type of string parsing like this. I'm not sure how much of this information you want to retain, but I would perhaps use Python's split() function to split on = to get rid of the equals sign, then strip the whitespace out of the second piece of the pie.
First, I would mask out the header/footer info I know I don't need, then do something akin to the following:
Let's take a chunk and save it in test1.txt:
ADDRESS= {Location Address}
SUBURB= {Location Suburb}
STATE= xxx
POSTCODE= xxx
DEPOSITED PLAN NO= 0
SECTION & HUNDRED NO= 0
PROPERTY PHONE NO=
Here's a small python snippet:
>>> f = open("test1.txt", "r")
>>> l = f.readlines()
>>> l = [line.split('=') for line in l]
>>> for line in l:
print line
['ADDRESS', '{Location Address}']
['SUBURB', '{Location Suburb}']
['STATE', 'xxx']
['POSTCODE', 'xxx']
['DEPOSITED PLAN NO', '0']
['SECTION & HUNDRED NO', '0']
['PROPERTY PHONE NO', '']
This would essentially give you a [Column, Value] tuple you could use to insert the data into your database (after escaping all strings, etc etc, SQL Injection warning).
This is assuming the email input and your DB will have the same column names, but if they didn't, it'd be fairly trivial to set up a column mapping using a dictionary. On the flip side, if the email and columns are in sync, you don't need to know the names of the columns to get the parsing down.
You could iterate through the pseudo-dictionary and print out each key-value pair in the right spot in your parameterized sql string.
Hope this helps!
Edit: While this is in Python, C#/VB.net should have the same/similar abilities.
Using f As StreamReader = File.OpenText("sample.txt")
Dim g As String = "undefined"
Do
Dim s As String = f.ReadLine
If s Is Nothing Then Exit Do
s = s.Replace(Chr(9), " ")
If s.StartsWith("[") And s.EndsWith("]") Then
g = s.Substring("[".Length, s.Length - "[]".Length)
Else
Dim ss() As String = s.Split(New Char() {"="c}, 2)
If ss.Length = 2 Then
Console.WriteLine("{0}.{1}={2}", g, Trim(ss(0)), Trim(ss(1)))
End If
End If
Loop
End Using