本文整理匯總了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);
}
}
}
}
}