Search code examples
javageopackage

how to take List<Point> from mil.nga.sf.Geometry


In my mil.nga.sf.geometry object I am getting geometry type, hasM, hasZ and point.

In my debugging I am able to see that geometry object contains list of point objects, But I am not able to take them into a list.

I am able to get the methods like getGeometryType, hasM(), hasZ() methods, but when I try to say geometry.getPoints it is not showing that method

In my geometry object I am getting List, but I am not able to take them into a list.

How can I take that list< point> into a list.

mil.nga.sf.Geometry geometry = GeometryReader.readGeometry(reader);

Solution

  • You can use LineString to get the List<Point>

    LineString geometry1 = null;  
        List<Point> points = null;     
        if (geometry instanceof mil.nga.sf.LineString) {
               geometry1 = new LineString((mil.nga.sf.LineString) geometry);
        }
        if(null != geometry1) {
            points = geometry1.getPoints();
        }