How to create a gml file from Java code

2.3k Views Asked by At

I want to create an application which require to create a .gml file using Java. And I want to add elements in that newly created .gml file from a text file.

How can I do so?

3

There are 3 best solutions below

0
On

Since GML is an XML dialect, I'd say the best way is to take your GML application schema and use JAX-B to generate an Object model from it, then parse the text format, transfer the data to the objext model and use JAX-B to marshal it to XML.

0
On

I'm guessing that you have legacy output of some form without explicit markup and that it has geo-coordinates in it. There is no simple or easy answer to that - we are engaged in writing parsers that will extract geo-coordinates from free text and it's a long process, involving heuristics and without 100% recall/precision.

Sometimes you have semi-structured documents - such as Wikipedia and it is easier - but not trivial - to write a geo-coordinate scraper.

But you should give more details of your potential inputs.

2
On

All a .gml file is a file that starts with #define script_name Then you put your code below that.