Capan
Capan

Reputation: 736

How can I draw a polygon on intersection coordinates on Nutiteq?

Hey people this is going to be my first question so dont hit me too hard !

Before I have already added polygons but the intersection is a bit complicating.

with pre-defined i mean for example intersection coordinates of two other polygons. I'm calculating the area of the polygon intersection but i also want to highlight the area. Thanks

Upvotes: 0

Views: 401

Answers (2)

JaakL
JaakL

Reputation: 4295

You would need two steps:

  1. calculate intersection: polygon from 2 polygons. I would use JTS for it, you would need to provide data in JTS objects.

  2. highlight the intersection on mapview (nutiteq for example). You can just add the resulting polygon as one geometry element into geometry layer, just as any other polygon. Use special styling to make it look different. You would need to convert JTS polygon to Nutiteq Polygon object to show it on map

Upvotes: 0

Capan
Capan

Reputation: 736

ArrayList<MapPos> keslist = new ArrayList<MapPos>();
for (int i = 0; i < sonuc.getNumPoints(); i++) {
        double lon = sonuc.getX(i);
        double lat = sonuc.getY(i);
MapPos mPos = new MapPos(lon, lat);
        keslist.add(mPos);
    }
PolygonStyle polygonStyle = PolygonStyle.builder().setColor(Color.GREEN).build();
    StyleSet<PolygonStyle> polygonStyleSet = new StyleSet<PolygonStyle>(null);
    polygonStyleSet.setZoomStyle(10, polygonStyle);
Polygon KesisimPol = new Polygon(keslist, new DefaultLabel("Kesişim"), polygonStyleSet, null);
GeometryLayer geomLayer = new GeometryLayer(mapView.getLayers().getBaseLayer().getProjection());
    mapView.getLayers().addLayer(geomLayer);
    geomLayer.add(KesisimPol);
}

Here is my solution. I've tried it works. Right now I'm trying to add this new polygon to editable objects layer. Because I can't use the result polygon in another intersection process.

I hope this will help the others.

Upvotes: 0

Related Questions