How is the better way to store a polyline (google maps) in a data base?
First sorry my English... I have to store a lot of polyline in a data base. It ocurred to me create a table call "points" and store all points from each polyline. Another thing that occurred to me is serial开发者_运维百科ize (with php) the polilynes and store in a single row each polilyne
Which option thinks are better?
Very Thanks
If you're not married to MySQL, PostgreSQL has a PostGIS extension that natively handles geographic data, including queries against it.
If you're set on MySQL, I'd do it as points, so you can query against individual points. Serialization might be a little more efficient to fetch the line, but it ruins querying.
Creating a table to store each point individually sounds like overkill and excessive normalization, unless you want to perform queries over these points.
I would simply serialize them to a string and store them in a text field.
Either/or. You can normalize the design with your Points table, or put all of the points in one field of your Polyline table.
The first is more extensible and has the DB model your data more closely. The second would involve fewer reads/writes to the DB and could be faster, but would require you to parse the points out in your code, and it would be more difficult to search for a particular point.
Depends on your application. :)
Creating a table of points with another relation mapping the set to a polyline/polygon is not bad practice. I have written several 1-off GIS schema with this approach. Yes, some DBs have spatial extensions but you can do a lot of other work too being able to simply adjust single points, scale them, &c.
There is a point of normalization, I say utilize it.
Mysql has an extensión for spatial data, here is the link: http://dev.mysql.com/doc/refman/5.7/en/spatial-extensions.html hope it will be some help for someone.
精彩评论