本文整理汇总了Java中com.vividsolutions.jts.geom.Polygon.getCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.getCoordinates方法的具体用法?Java Polygon.getCoordinates怎么用?Java Polygon.getCoordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.Polygon
的用法示例。
在下文中一共展示了Polygon.getCoordinates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.vividsolutions.jts.geom.Polygon; //导入方法依赖的package包/类
public static void main(String[] args) {
ReedsSheppCarPlanner rsp = new ReedsSheppCarPlanner();
Coordinate footprint1 = new Coordinate(-2.0,0.5);
Coordinate footprint2 = new Coordinate(2.0,0.5);
Coordinate footprint3 = new Coordinate(2.0,-0.5);
Coordinate footprint4 = new Coordinate(-2.0,-0.5);
rsp.setRadius(0.5);
rsp.setFootprint(footprint1,footprint2,footprint3,footprint4);
JTSDrawingPanel panel = JTSDrawingPanel.makeEmpty("debug");
GeometryFactory gf = new GeometryFactory();
Polygon footprint = gf.createPolygon(new Coordinate[] {footprint1,footprint2,footprint3,footprint4,footprint1});
Polygon smoothedFootprint = gf.createPolygon(rsp.getCollisionCircleCenters());
System.out.println("Smoothing went from " + footprint.getCoordinates().length + " to " + smoothedFootprint.getCoordinates().length + " points");
panel.addGeometry("orig", footprint, true, true, true, "#00FF00");
panel.addGeometry("smooth", smoothedFootprint, false, false, true, "#FF0000");
for (int i = 0; i < smoothedFootprint.getCoordinates().length; i++) {
double delta = 0.1;
Coordinate p1 = new Coordinate(smoothedFootprint.getCoordinates()[i].x,smoothedFootprint.getCoordinates()[i].y);
Coordinate p2 = new Coordinate(smoothedFootprint.getCoordinates()[i].x+delta,smoothedFootprint.getCoordinates()[i].y+delta);
Coordinate p3 = new Coordinate(smoothedFootprint.getCoordinates()[i].x-delta,smoothedFootprint.getCoordinates()[i].y+delta);
panel.addGeometry("_cp"+i, gf.createPolygon(new Coordinate[] {p1,p2,p3,p1}), false, false, false, "#000000");
}
}
示例2: render
import com.vividsolutions.jts.geom.Polygon; //导入方法依赖的package包/类
@Override
public void render(Object glC) {
OpenGLContext context=(OpenGLContext)glC;
super.render(context);
//OpenGLContext context=SumoPlatform.getApplication().getGeoContext();
if (!context.isDirty() || glayer == null||SumoPlatform.isBatchMode()) {
return;
}
int x = context.getX(), y = context.getY();
float zoom = context.getZoom(), width = context.getWidth() * zoom, height = context.getHeight() * zoom;
for(Additionalgeometries geometry : additionalGeometriesMap.values()){
// check geometries need to be displayed
if(geometry.isStatus()){
if (geometry.getType().equalsIgnoreCase(GeometryImage.POINT)) {
GL2ShapesRender.renderPolygons(context,width,height,geometry.getGeometries(),geometry.getLinewidth(),geometry.getColor());
} else if (geometry.getType().equalsIgnoreCase(GeometryImage.POLYGON)) {
for (Geometry tmp : geometry.getGeometries()) {
List<Geometry>gs=new ArrayList<>();
if(tmp instanceof MultiPolygon){
MultiPolygon mp=(MultiPolygon)tmp;
for (int ig=0;ig<mp.getNumGeometries();ig++) {
gs.add(mp.getGeometryN(ig));
}
}else{
gs.add(tmp);
}
for (Geometry g : gs) {
Polygon polygon=(Polygon)g;
if (polygon.getCoordinates().length < 1) {
continue;
}
GL2ShapesRender.drawPoly(context,polygon.getCoordinates(),width,height,x,y,geometry.getLinewidth(),color);
/*int interior=polygon.getNumInteriorRing();
if(interior>0){
//draw external polygon
LineString line=polygon.getExteriorRing();
GL2ShapesRender.drawPoly(context,line.getCoordinates(),width,height,x,y,geometry.getLinewidth(),color);
//draw holes
for(int i=0;i<interior;i++){
LineString line2=polygon.getInteriorRingN(i);
GL2ShapesRender.drawPoly(context,line2.getCoordinates(),width,height,x,y,geometry.getLinewidth(),color);
}
}else{
GL2ShapesRender.drawPoly(context,polygon.getCoordinates(),width,height,x,y,geometry.getLinewidth(),color);
}*/
}
}
} else if (geometry.getType().equalsIgnoreCase(GeometryImage.LINESTRING)) {
for (Geometry temp : geometry.getGeometries()) {
if (temp.getCoordinates().length < 1) {
continue;
}
GL2ShapesRender.renderPolygon(context,width,height,temp.getCoordinates(),geometry.getLinewidth(),color);
}
}
}
}
}