KML import in MYSQL

2,581 views
Skip to first unread message

Livetrader30

unread,
Nov 9, 2006, 1:09:47 PM11/9/06
to KML Discussions
Hi,
I know, how to read xml files into MySQL using php. Is it possible to read kml files into MySQL using php. Do you have some scripts. Thank you in advance.

Best regards
Live

tekgergedan

unread,
Nov 9, 2006, 1:13:51 PM11/9/06
to KML Discussions
Hi

I tried that but not much easy. Kml is being changed as it is beta. Better to wait it get stable.

ManoM

unread,
Nov 9, 2006, 1:37:24 PM11/9/06
to KML Discussions
Hi Livetrader30,

tekgergedan has a good point, KML has been changing a lot. If your implementation is tied to the structure of the file, you may want to hold off, or at least be willing to keep on top of changes.

If you want to proceed, however, KML files are essentially XML, so there should be no difference. Just be mindful of the .kml extension.

KMZ files are zipped KML files, so you'll have to crack that open with an unzip app first.

ManoM

Livetrader30

unread,
Nov 9, 2006, 1:39:16 PM11/9/06
to KML Discussions
Thank you for your response!
I want to give people the ability to upload their kml/kmz files directly into a database (like MySQL).

Best regards
Live

Robert_Lipe

unread,
Nov 9, 2006, 2:59:55 PM11/9/06
to KML Discussions
A lot depends on what kind of information you're hoping to pull out of the KML. If you want the whole shebang, you're in the land of parsing the KML yourself and figuring out a sane way to represent that in SQL.. Brace yourself. If you really only care about GPS-ish things (waypoints, tracks, names, descriptions, etc.) and not things like camera angles and line widths and colors it's not too bad.

I did a contract project where I was faced with a similar problem a few months ago and it occurred to me that a custom output format for GPSBabel could do the KML parsing and hock up the 'insert into' lines. I don't recall if I had to post-process the output, but I do remember it made it a pretty trivial problem.

It handles only a small subset of the things expressible in KML but it solved the problem at hand.

(It may have also been an "everything looks like a nail" approach to the solution.)

ManoM

unread,
Nov 9, 2006, 6:41:45 PM11/9/06
to KML Discussions
Hi Livetrader30,

The easiest and least useful is to upload them as BLOB files. Another solution would be to use an open-source XML database, which would allow you to store them as XML and query using XQuery. Another solution is to parse the file into the database and then re-assemble it when you want to access the data.

ManoM

Valery35

unread,
Nov 10, 2006, 9:52:29 AM11/10/06
to KML Discussions
It is problem.
1. KML not have XSD schema.
2. KML can have hard structure and many of datatypes.

I make export KML to ArcGIS data. It is near operation. This work for single KML only and not store of KML structure. http://gis.mi-perm.ru/programs/kmler/index.html

Livetrader30

unread,
Nov 10, 2006, 11:21:45 AM11/10/06
to KML Discussions
Ok, I did not ask the question exactly. I would give the possibility to people of loading 3D buildings by kml on a MySQL data base. Afterwards a new kml file will be written that refers to the old and updatet buildings. I do not need camera angles or something like that. Perhaps textures.


Thank you for your answers.

Best regards
Live

ManoM

unread,
Nov 10, 2006, 11:40:43 AM11/10/06
to KML Discussions
Hi Livetrader30,

So, what I understand is that you're trying to allow people to upload 3D buildings designed in SketchUp in Collada format, and put those into a MySQL database, which can then be used to generate a new KML document, perhaps at a location selected by the user.

That doesn't seem that difficult. You could store the Collada file in a BLOB format with the textures in a related table, also in a BLOB format, or with links to their locations in a directory structure. I'd do some Google searches on Collada and MySQL.

ManoM

Valery35

unread,
Nov 10, 2006, 2:59:38 PM11/10/06
to KML Discussions
If you need only save-load this files, then maybe you simple use engine of this forum? UBB?
This forum also use MySQL as KML storage.

http://www.ubbcentral.com/

I think about

Livetrader30

unread,
Nov 14, 2006, 4:12:14 AM11/14/06
to KML Discussions
Thank you very much ManoM,

I will try this method and search for the BLOB format.

Best regards
Live
Reply all
Reply to author
Forward
0 new messages