本文整理汇总了Java中org.geotools.geojson.geom.GeometryJSON.read方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryJSON.read方法的具体用法?Java GeometryJSON.read怎么用?Java GeometryJSON.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.geojson.geom.GeometryJSON
的用法示例。
在下文中一共展示了GeometryJSON.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGeometry
import org.geotools.geojson.geom.GeometryJSON; //导入方法依赖的package包/类
public static Geometry createGeometry(String str) {
GeometryJSON j = new GeometryJSON();
try {
return j.read(str.replace("'", "\""));
} catch (IOException e) {
throw new RuntimeException("Failed to create a geometry from given str " + str, e);
}
}
示例2: call
import org.geotools.geojson.geom.GeometryJSON; //导入方法依赖的package包/类
public Object call(Properties bindings, Object[] args) {
if(args.length==1){
GeometryJSON gjson = new GeometryJSON();
String json = args[0].toString();
Reader reader = new StringReader(json);
try {
return gjson.read(reader);
}
catch (java.io.IOException e) {
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + ": " + e.getMessage());
}
}
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 1 argument");
}
示例3: testEpsg
import org.geotools.geojson.geom.GeometryJSON; //导入方法依赖的package包/类
@Test
public void testEpsg() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setRequestURI("/rest/beans");
request.setMethod("GET");
MockHttpServletResponse response = new MockHttpServletResponse();
// check attribute equality
request.setParameter("queryable", "stringAttr");
request.setParameter("stringAttr_eq", "bean1");
request.setParameter("epsg", "900913");
ModelAndView mav = adapter.handle(request, response, restController);
view.render(mav.getModel(), request, response);
response.flushBuffer();
Object json = new JSONParser().parse(response.getContentAsString());
Assert.assertTrue(json instanceof JSONObject);
JSONObject jsonObject = (JSONObject) json;
JSONArray features = (JSONArray) jsonObject.get("features");
JSONObject feature = (JSONObject) features.get(0);
JSONObject geometry = (JSONObject) feature.get("geometry");
GeometryJSON g = new GeometryJSON(0);
Geometry m = g.read(geometry.toJSONString());
Envelope envelope = new Envelope(0, 1, 0, 1);
Geometry orig = JTS.toGeometry(envelope);
Geometry m2 = geoservice.transform(orig, "EPSG:4326", "EPSG:900913");
// equality check on buffer, JTS equals does not do the trick !
Assert.assertTrue(m.buffer(0.01).contains(m2));
Assert.assertTrue(m2.buffer(0.01).contains(m));
}