本文整理汇总了Java中org.geomajas.geometry.service.WktService.toGeometry方法的典型用法代码示例。如果您正苦于以下问题:Java WktService.toGeometry方法的具体用法?Java WktService.toGeometry怎么用?Java WktService.toGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geomajas.geometry.service.WktService
的用法示例。
在下文中一共展示了WktService.toGeometry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toGeometry
import org.geomajas.geometry.service.WktService; //导入方法依赖的package包/类
/**
* Parse the given Well Known Text string into a geometry.
*
* @param wkt
* The WKT text.
* @return The resulting geometry, or null in case something went wrong.
*/
public Geometry toGeometry(String wkt) {
try {
return WktService.toGeometry(wkt);
} catch (WktException e) {
return null;
}
}
示例2: onMapModelChanged
import org.geomajas.geometry.service.WktService; //导入方法依赖的package包/类
/**
* add some world paintables, these will be printed too !!!
*/
@Override
public void onMapModelChanged(MapModelChangedEvent event) {
try {
Rectangle bg = new Rectangle("background");
bg.setBounds(new Bbox(0, 0, 4000000, 4000000));
bg.setStyle(new ShapeStyle("#FFFFFF", 1f, "#FFFFFF", 1f, 2));
map.registerWorldPaintable(bg);
Rectangle rect = new Rectangle("my rect");
rect.setBounds(new Bbox(0, 0, 1000000, 1000000));
rect.setStyle(createStyle("#FF0000"));
map.registerWorldPaintable(rect);
Circle circle = new Circle("my circle");
circle.setPosition(new Coordinate(1500000, 1500000));
circle.setRadius(500000f);
circle.setStyle(createStyle("#00FF00"));
map.registerWorldPaintable(circle);
GfxGeometry triangle = new GfxGeometry("triangle");
Geometry geom;
geom = WktService
.toGeometry("POLYGON ((2000000 2000000, 3000000 2000000,3000000 3000000,2000000 2000000))");
triangle.setGeometry(GeometryConverter.toGwt(geom));
triangle.setStyle(createStyle("#FFFF00"));
map.registerWorldPaintable(triangle);
Image image = new Image("osgeo");
image.setHref("http://live.osgeo.org/_images/logo-geomajas.png");
image.setBounds(new Bbox(0, 2000000, 1000000, 1000000));
image.setStyle(new PictureStyle(0.7));
map.registerWorldPaintable(image);
Text text = new Text("my text", "Hello world", new Coordinate(2000000, 2000000), new FontStyle(
"#00FFF0", 50, "Verdana", "bold", "italic"));
map.registerWorldPaintable(text);
} catch (WktException e) {
}
}
示例3: onGeometryBtnClicked
import org.geomajas.geometry.service.WktService; //导入方法依赖的package包/类
@UiHandler("geometryBtn")
public void onGeometryBtnClicked(ClickEvent event) {
try {
Geometry polygon = WktService
.toGeometry("POLYGON ((0 0, 0 0.7, 0.7 0.7, 0 0),(0.1 0.2, 0.1 0.4, 0.3 0.4, 0.1 0.2))");
Geometry line = WktService.toGeometry("LINESTRING (-2 0, -2 0.7, -1.3 0, -1.3 0.7)");
Geometry point = WktService.toGeometry("POINT (-3.5 0.5)");
Geometry multiPolygon = new Geometry(Geometry.MULTI_POLYGON, 0, 5);
Matrix m1 = new Matrix(1, 0, 0, 1, -0.5, -2);
Matrix m2 = new Matrix(1, 0, 0, 1, 0.5, -2);
Matrix m3 = new Matrix(1, 0, 0, 1, 0, -1);
multiPolygon.setGeometries(new Geometry[] { transform(polygon, m1), transform(polygon, m2),
transform(polygon, m3), });
Geometry multiLinestring = new Geometry(Geometry.MULTI_LINE_STRING, 0, 5);
multiLinestring.setGeometries(new Geometry[] { transform(line, m1), transform(line, m2),
transform(line, m3), });
Geometry mp = new Geometry(Geometry.MULTI_POINT, 0, 5);
mp.setGeometries(new Geometry[] { transform(point, m1), transform(point, m2), transform(point, m3), });
container.add(scaleAndStyle(polygon));
container.add(scaleAndStyle(line));
container.add(scaleAndStyle(point));
container.add(scaleAndStyle(multiPolygon));
container.add(scaleAndStyle(multiLinestring));
container.add(scaleAndStyle(mp));
} catch (WktException e) {
// not possible
}
}