How to store lat/long in MySQL database
I'm working on Google map API. after i choose the start and end point the map return the routed way as a path on the google map, and i have track the lat/lng from the routed path as follows [ the coordinates below are the lat/long of a routed line]
13.692941, 100.750723,
13.70649,100.75405999999998,
13.71334,100.75428999999997,
13.72268,100.74638000000004,
13.72775,100.74631,
13.8153,100.73532999999998,
13.81332,100.73160000000007,
i want to store all these lat/long in MySQL database. i found that there is Spatial extension in MySQL. and there is a way to开发者_如何学编程 insert lat/long as linestring
insert into geom (g)
values (GeomFromText('linestring(2 3,7 5,10 10)'))
i wanna know how to add all those above lat long into linestring function? or there is another suggestion?
You can store these lat/lon DATA like bellow -
$arr = array("13.692941, 100.750723",
"13.70649,100.75405999999998",
"13.71334,100.75428999999997",
"13.72268,100.74638000000004");
// serialize data before save to database, you should deserialized that when you will use this data after query.
$serializedArr = serialize($arr);
insert into geom (g) values ("{$serializedArr}");
精彩评论