Thanks Ian, any idea what was the last version compile with java 7? attempting to get this to work in an older android sdk environment
On Sat, Aug 19, 2017 at 3:03 PM, Ian Turton <ijtur...@gmail.com> wrote: > > > On 19 August 2017 at 19:18, Alex O'Ree <spyhunte...@gmail.com> wrote: >> >> Does geotools have a mechanism to convert shape files to KML? > > > Yes, its the same as any other format, read in the shapefile and write out > the KML > > public static void main(String[] args) throws IOException { > File infile = new File(args[0]); > DataStore inputDataStore = DataStoreFinder.getDataStore( > Collections.singletonMap("url", URLs.fileToUrl(infile))); > > String inputTypeName = inputDataStore.getTypeNames()[0]; > SimpleFeatureType inputType = inputDataStore.getSchema(inputTypeName); > > FeatureSource<SimpleFeatureType, SimpleFeature> > source = inputDataStore.getFeatureSource(inputTypeName); > > FeatureCollection<SimpleFeatureType, SimpleFeature> > inputFeatureCollection = source.getFeatures(); > Encoder encoder = new Encoder(new KMLConfiguration()); > encoder.setIndenting(true); > ByteArrayOutputStream os = new ByteArrayOutputStream(); > try { > encoder.encode(inputFeatureCollection, KML.kml, os ); > String out = os.toString().replaceAll("kml:", ""); > System.out.println(out); > } catch (Exception e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > } > > Ian >> >> >> Alternatively, are there any guides for how to iterate over this >> >> SimpleFeatureSource featureSource = store.getFeatureSource(); >> >> and pull out the lat/lon points on each shape/feature/polygon? >> >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> GeoTools-GT2-Users mailing list >> GeoTools-GT2-Users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > > > > -- > Ian Turton ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users