Hello friends,
I was able to generate the KML from SimpleFeature instances. After
converting the features to ploygons as opposed to multiploygon, i captured
the coordinates and wrote them to a file on the fly.
I thought I would share with whoever is interested.
Best wishes,
Ahmed
BufferedWriter out = new BufferedWriter(new
FileWriter("data/wwf-x-y-coordinates-area.kml", true));
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
out.write("\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">");
out.write("\n\t<Placemark>");
out.write("\n\t\t<name>WWWF EcoRegions Database</name>");
for(SimpleFeature feature: listOfFeatures){
List<Polygon> tmpPloygons = getGeomAsPolygon(feature);//
contact me if you need this method.
for(Polygon poly: tmpPloygons){
if(!listOfPloygons.contains(poly)){
out.write("\n\t\t<point>");
out.write("\n\t\t\t<coordinates>");
out.write(poly.getCoordinate().x +","+
poly.getCoordinate().y);
out.write("</coordinates>");
out.write("\n\t\t</point>");
//listOfPloygons.add(poly);
}
}
}
out.write("\n\t</Placemark>");
out.write("\n</kml>");
out.write("\n");
out.close();
On Fri, Apr 16, 2010 at 1:53 PM, Ahmed Abdeen Hamed <[email protected]
> wrote:
> Thanks Jody!
> I am not sure if I made my question clear. I have a shapefile that I want
> to visualize via GoogleEarth. I don't have any XML file to parse to begin
> with. Is it possible to manipulate the shapefile to get a GML or KML?
> Thanks very much!
> Ahmed
>
>
> On Sat, Apr 10, 2010 at 9:13 AM, Jody Garnett <[email protected]>wrote:
>
>> Publish via geoserver :-)
>>
>> There are KML bindings for the parser / encoder. They should work in a
>> similar manner to parsing / encoding GML - have a look at the test cases to
>> see how it is actually done.
>> Jody
>>
>> On 10/04/2010, at 6:58 AM, Ahmed Abdeen Hamed wrote:
>>
>> > Hello friends,
>> > Can you share some examples of how to convert a shapefile to KML? I have
>> looked at the API's and I know that it supports KML but can't find quick
>> examples to work with.
>> > I would appreciate any help on that.
>> > Thanks,
>> > Ahmed
>> >
>> ------------------------------------------------------------------------------
>> > Download Intel® Parallel Studio Eval
>> > Try the new software tools for yourself. Speed compiling, find bugs
>> > proactively, and fine-tune applications for parallel performance.
>> > See why Intel Parallel Studio got high marks during beta.
>> >
>> http://p.sf.net/sfu/intel-sw-dev_______________________________________________
>> > Geotools-gt2-users mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users