本文整理汇总了Java中com.esri.core.geometry.GeometryEngine.geometryFromWkt方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryEngine.geometryFromWkt方法的具体用法?Java GeometryEngine.geometryFromWkt怎么用?Java GeometryEngine.geometryFromWkt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esri.core.geometry.GeometryEngine
的用法示例。
在下文中一共展示了GeometryEngine.geometryFromWkt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPolygon
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testPolygon() throws IOException, JSONException {
Properties properties = new Properties();
properties.load(new FileInputStream("config/oberbayern.properties"));
RoadReader reader = Loader.reader(properties);
Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt(
"POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))",
WktImportFlags.wktImportDefaults, Type.Polygon);
BaseRoad road = null;
reader.open(polygon, null);
int count = 0;
while ((road = reader.next()) != null) {
assertTrue(
GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326))
|| GeometryEngine.contains(polygon, road.geometry(),
SpatialReference.create(4326)));
count += 1;
}
reader.close();
assertTrue(count > 0);
}
示例2: testExclusion
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testExclusion() throws IOException, JSONException {
Properties properties = new Properties();
properties.load(new FileInputStream("config/oberbayern.properties"));
RoadReader reader = Loader.reader(properties);
Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt(
"POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))",
WktImportFlags.wktImportDefaults, Type.Polygon);
HashSet<Short> exclusion = new HashSet<>(Arrays.asList((short) 117));
BaseRoad road = null;
reader.open(polygon, exclusion);
int count = 0;
while ((road = reader.next()) != null) {
assertTrue(
GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326))
|| GeometryEngine.contains(polygon, road.geometry(),
SpatialReference.create(4326)));
assertTrue(!exclusion.contains(road.type()));
count += 1;
}
reader.close();
assertTrue(count > 0);
}
示例3: testJSON
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testJSON() throws JSONException {
String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)";
BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F,
(Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults,
Geometry.Type.Polyline));
RoadMap map = new RoadMap();
map.add(new Road(osm, Heading.forward));
RoadPoint point1 = new RoadPoint(map.get(0L), 0.2);
String json = point1.toJSON().toString();
RoadPoint point2 = RoadPoint.fromJSON(new JSONObject(json), map);
assertEquals(point1.edge().id(), point2.edge().id());
assertEquals(point1.fraction(), point2.fraction(), 1E-6);
assertEquals(point1.edge().source(), point2.edge().source());
assertEquals(point1.edge().target(), point2.edge().target());
}
示例4: testJSON
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testJSON() throws JSONException {
String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)";
BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F,
(Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults,
Geometry.Type.Polyline));
Road road = new Road(osm, Heading.forward);
RoadMap map = new RoadMap();
map.add(road);
String json = road.toJSON().toString();
Road road2 = Road.fromJSON(new JSONObject(json), map);
assertEquals(road, road2);
}
示例5: evaluate
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public BytesWritable evaluate(Text wkwrap, int wkid) throws UDFArgumentException {
String wkt = wkwrap.toString();
try {
Geometry geomObj = GeometryEngine.geometryFromWkt(wkt,
0,
Geometry.Type.Unknown);
SpatialReference spatialReference = null; // Idea: OGCGeometry.setSpatialReference after .fromText
if (wkid != GeometryUtils.WKID_UNKNOWN) {
spatialReference = SpatialReference.create(wkid);
}
OGCGeometry ogcObj = OGCGeometry.createFromEsriGeometry(geomObj, spatialReference);
return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj);
} catch (Exception e) { // IllegalArgumentException, GeometryException
LogUtils.Log_InvalidText(LOG, wkt);
return null;
}
}
示例6: MatcherSample
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
* Creates a {@link MatcherSample} object from its JSON representation.
*
* @param json JSON representation of {@link MatcherSample} object. JSONException thrown on JSON
* extraction or parsing error.
* @throws JSONException thrown on JSON parse error.
*/
public MatcherSample(JSONObject json) throws JSONException {
super(json);
id = json.getString("id");
String wkt = json.getString("point");
point = (Point) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults,
Type.Point);
if (json.has("azimuth")) {
azimuth = norm(json.getDouble("azimuth"));
} else {
azimuth = Double.NaN;
}
}
示例7: open
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Override
public void open() throws SourceException {
if (roads.isEmpty()) {
for (Entry entry : entries) {
Polyline geometry = (Polyline) GeometryEngine.geometryFromWkt(entry.five(),
WktImportFlags.wktImportDefaults, Type.Polyline);
roads.add(new BaseRoad(entry.one(), entry.two(), entry.three(), entry.one(),
entry.four(), (short) 0, 1.0f, 100.0f, 100.0f,
(float) spatial.length(geometry), geometry));
}
}
iterator = roads.iterator();
}
示例8: testPathInterception1
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testPathInterception1() {
String point = "POINT(11.410624 48.144161)";
String line =
"LINESTRING(11.4047013 48.1402147,11.4047038 48.1402718,11.4047661 48.1403687,11.4053519 48.141055,11.4054617 48.1411901,11.4062664 48.1421968,11.4064586 48.1424479,11.4066449 48.1427372,11.4067254 48.1429028,11.4067864 48.1430673,11.4068647 48.1433303,11.4069456 48.1436822,11.4070524 48.1440368,11.4071569 48.1443314,11.4072635 48.1445915,11.4073887 48.1448641,11.4075228 48.1450729,11.407806 48.1454843,11.4080135 48.1458112,11.4083012 48.1463167,11.4086211 48.1469061,11.4087461 48.1471386,11.4088719 48.1474078,11.4089422 48.1476014,11.409028 48.1478353,11.409096 48.1480701,11.4091568 48.1483459,11.4094282 48.1498536)";
Point c = (Point) GeometryEngine.geometryFromWkt(point, WktImportFlags.wktImportDefaults,
Type.Point);
Polyline ab = (Polyline) GeometryEngine.geometryFromWkt(line,
WktImportFlags.wktImportDefaults, Type.Polyline);
sw1.start();
double f = spatial.intercept(ab, c);
sw1.stop();
double l = spatial.length(ab);
sw2.start();
Point p = spatial.interpolate(ab, l, f);
sw2.stop();
double d = spatial.distance(p, c);
assertEquals(p.getX(), 11.407547966254612, 10E-6);
assertEquals(p.getY(), 48.14510945890138, 10E-6);
assertEquals(f, 0.5175157549609246, 10E-6);
assertEquals(l, 1138.85464239099, 10E-6);
assertEquals(d, 252.03375312704165, 10E-6);
if (benchmark) {
System.out.println("[Geography] path interception " + sw1.us()
+ " us (gnomonic), path interpolation " + sw2.us() + " us (geodesic)");
}
}
示例9: testPathInterception2
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testPathInterception2() {
String point = "POINT(11.584009286555187 48.17578656762985)";
String line =
"LINESTRING(11.5852021 48.1761996, 11.585284 48.175924, 11.5852937 48.1758945)";
Point c = (Point) GeometryEngine.geometryFromWkt(point, WktImportFlags.wktImportDefaults,
Type.Point);
Polyline ab = (Polyline) GeometryEngine.geometryFromWkt(line,
WktImportFlags.wktImportDefaults, Type.Polyline);
sw1.start();
double f = spatial.intercept(ab, c);
sw1.stop();
double l = spatial.length(ab);
sw2.start();
Point p = spatial.interpolate(ab, l, f);
sw2.stop();
double d = spatial.distance(p, c);
assertEquals(p.getX(), 11.585274842230357, 10E-6);
assertEquals(p.getY(), 48.17595481677191, 10E-6);
assertEquals(f, 0.801975106391962, 10E-6);
assertEquals(l, 34.603061318901396, 10E-6);
assertEquals(d, 95.96239015496631, 10E-6);
if (benchmark) {
System.out.println("[Geography] path interception " + sw1.us()
+ " us (gnomonic), path interpolation " + sw2.us() + " us (geodesic)");
}
}
示例10: testLineInterception
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testLineInterception() {
Polyline ab = (Polyline) GeometryEngine.geometryFromWkt(
"LINESTRING(11.4047661 48.1403687,11.4053519 48.141055)",
WktImportFlags.wktImportDefaults, Type.Polyline);
Point a = ab.getPoint(0), b = ab.getPoint(1);
String points[] = new String[] {"POINT(11.406501117689324 48.14051652560591)", // East
"POINT(11.406713245538327 48.14182906667162)", // Northeast
"POINT(11.404923416812364 48.14258477213369)", // North
"POINT(11.403300759321036 48.14105540093837)", // Northwest
"POINT(11.403193249043934 48.140881120346386)", // West
"POINT(11.40327279698731 48.13987351306362)", // Southwest
"POINT(11.405221721600025 48.1392039845402)", // South
"POINT(11.406255844863914 48.13963486923349)" // Southeast
};
for (int i = 0; i < points.length; ++i) {
Point c = (Point) GeometryEngine.geometryFromWkt(points[i],
WktImportFlags.wktImportDefaults, Type.Point);
sw1.start();
double f = spatial.intercept(a, b, c);
Point p = spatial.interpolate(a, b, f);
sw1.stop();
sw2.start();
Triple<Point, Double, Double> res = intercept(a, b, c);
sw2.stop();
sw3.start();
double s = spatial.distance(p, c);
sw3.stop();
sw4.start();
double s_esri = distance(p, c);
sw4.stop();
if (benchmark) {
System.out.println("[Geography] interception & interpolation " + sw1.us()
+ " us (gnomonic/geodesic) " + sw2.us() + " us (iterative)");
System.out.println("[Geography] distance " + sw3.us() + " us (GeoLib) " + sw4.us()
+ " us (ESRI)");
}
assertEquals(f > 1 ? 1 : f < 0 ? 0 : f, res.three(), 0.2);
assertEquals(p.getX(), res.one().getX(), 10E-2);
assertEquals(p.getY(), res.one().getY(), 10E-2);
assertEquals(s, s_esri, 10E-6);
}
}
示例11: testJSON
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Test
public void testJSON() throws JSONException {
SpatialOperator spatial = new Geography();
/*
* (p2) (p3) ----- (e1) : (p1) -> (p2) ----------------------------------------------------
* - \ / --------- (e2) : (p3) -> (p1) ----------------------------------------------------
* | (p1) | ------ (e3) : (p4) -> (p1) ----------------------------------------------------
* - / \ --------- (e4) : (p1) -> (p5) ----------------------------------------------------
* (p4) (p5) ----- (e5) : (p2) -> (p4) ----------------------------------------------------
* --------------- (e6) : (p5) -> (p3) ----------------------------------------------------
*/
String p1 = "11.3441505 48.0839963";
String p2 = "11.3421209 48.0850624";
String p3 = "11.3460348 48.0850108";
String p4 = "11.3427522 48.0832129";
String p5 = "11.3469701 48.0825356";
Polyline geometry1 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p1 + "," + p2 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
Polyline geometry2 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p3 + "," + p1 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
Polyline geometry3 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p4 + "," + p1 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
Polyline geometry4 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p1 + "," + p5 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
Polyline geometry5 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p2 + "," + p4 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
Polyline geometry6 =
(Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p5 + "," + p3 + ")",
WktImportFlags.wktImportDefaults, Geometry.Type.Polyline);
List<BaseRoad> osm = new LinkedList<>();
osm.add(new BaseRoad(1L, 1L, 2L, 1L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry1), geometry1));
osm.add(new BaseRoad(2L, 3L, 1L, 2L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry2), geometry2));
osm.add(new BaseRoad(3L, 4L, 1L, 3L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry3), geometry3));
osm.add(new BaseRoad(4L, 1L, 5L, 4L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry4), geometry4));
osm.add(new BaseRoad(5L, 2L, 4L, 5L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry5), geometry5));
osm.add(new BaseRoad(6L, 5L, 3L, 6L, false, (short) 1, 1F, 60F, 60F,
(float) spatial.length(geometry6), geometry6));
RoadMap map = new RoadMap();
for (BaseRoad road : osm) {
map.add(new Road(road, Heading.forward));
map.add(new Road(road, Heading.backward));
}
map.construct();
RoadPoint point1 = new RoadPoint(map.get(2), 0.7);
RoadPoint point2 = new RoadPoint(map.get(10), 0.3);
List<Road> path = new LinkedList<>(Arrays.asList(map.get(2), map.get(10)));
Route route = new Route(point1, point2, path);
String json = route.toJSON().toString();
Route route2 = Route.fromJSON(new JSONObject(json), map);
assertEquals(route.size(), route2.size());
for (int i = 0; i < route.size(); ++i) {
assertEquals(route.get(i), route2.get(i));
}
}
示例12: ST_GeomFromText
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public static Geom ST_GeomFromText(String s, int srid) {
final Geometry g = GeometryEngine.geometryFromWkt(s,
WktImportFlags.wktImportDefaults, Geometry.Type.Unknown);
return bind(g, srid);
}
示例13: ST_LineFromText
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public static Geom ST_LineFromText(String wkt, int srid) {
final Geometry g = GeometryEngine.geometryFromWkt(wkt,
WktImportFlags.wktImportDefaults,
Geometry.Type.Line);
return bind(g, srid);
}
示例14: ST_MPointFromText
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public static Geom ST_MPointFromText(String wkt, int srid) {
final Geometry g = GeometryEngine.geometryFromWkt(wkt,
WktImportFlags.wktImportDefaults,
Geometry.Type.MultiPoint);
return bind(g, srid);
}
示例15: ST_PointFromText
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public static Geom ST_PointFromText(String wkt, int srid) {
final Geometry g = GeometryEngine.geometryFromWkt(wkt,
WktImportFlags.wktImportDefaults,
Geometry.Type.Point);
return bind(g, srid);
}