Dear All,

I have implemented the following code, but still I am struggling in getting
direct access to X and Y coordinates, to do some computations on them.

*the syntax:*

*System.out.println(feature.getDefaultGeometryProperty().getValue());*

shows coordinates' pairs, but I could not use them in my computations.

Any help will be appreciated.

*Java code*

        File file = new  File("LUX_adm2.shp");
        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();

        // Create a map content and add our shapefile to it
        MapContent map = new MapContent();
        map.setTitle("Display Shapefile");

        Style style;
        style = SLD.createSimpleStyle(featureSource.getSchema());

        Layer layer;
        layer = new FeatureLayer(featureSource, style);
        map.addLayer(layer);
        // Now display the map
        JMapFrame.showMap(map);

        Filter filter = Filter.INCLUDE;
        FeatureCollection collection = featureSource.getFeatures(filter);

        try (FeatureIterator<SimpleFeature> features =
collection.features()) {
            while (features.hasNext()) {
                SimpleFeature feature = features.next();
                System.out.println(feature.getID() + ": ");
                //System.out.print(": ");

System.out.println(feature.getDefaultGeometryProperty().getValue());

            }
        }


Best wishes,
Ahmed
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to