com.esri.core.geometry.WktImportFlags Java Examples
The following examples show how to use
com.esri.core.geometry.WktImportFlags.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostGISReaderTest.java From barefoot with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: PostGISReaderTest.java From barefoot with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: RoadTest.java From barefoot with Apache License 2.0 | 6 votes |
@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); }
Example #4
Source File: RoadPointTest.java From barefoot with Apache License 2.0 | 6 votes |
@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()); }
Example #5
Source File: RoadMapTest.java From barefoot with Apache License 2.0 | 5 votes |
private static List<BaseRoad> osmroads() { /* * (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"; List<BaseRoad> osm = new LinkedList<>(); osm.add(new BaseRoad(1L, 1L, 2L, 1L, true, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p1 + "," + p2 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); osm.add(new BaseRoad(2L, 3L, 1L, 2L, false, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p3 + "," + p1 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); osm.add(new BaseRoad(3L, 4L, 1L, 3L, true, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p4 + "," + p1 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); osm.add(new BaseRoad(4L, 1L, 5L, 4L, false, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p1 + "," + p5 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); osm.add(new BaseRoad(5L, 2L, 4L, 5L, false, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p2 + "," + p4 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); osm.add(new BaseRoad(6L, 5L, 3L, 6L, false, (short) 1, 1F, 60F, 60F, 100F, (Polyline) GeometryEngine.geometryFromWkt("LINESTRING(" + p5 + "," + p3 + ")", WktImportFlags.wktImportDefaults, Geometry.Type.Polyline))); return osm; }
Example #6
Source File: GeographyTest.java From barefoot with Apache License 2.0 | 5 votes |
@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)"); } }
Example #7
Source File: MatcherKStateTest.java From barefoot with Apache License 2.0 | 5 votes |
@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(); }
Example #8
Source File: MatcherTest.java From barefoot with Apache License 2.0 | 5 votes |
@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(); }
Example #9
Source File: MatcherSample.java From barefoot with Apache License 2.0 | 5 votes |
/** * 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; } }
Example #10
Source File: UserDefinedGeoJsonSpatialFilter.java From bboxdb with Apache License 2.0 | 5 votes |
/** * Convert the geojson element to a ESRI geometry * @param jsonString * @return */ private OGCGeometry geoJoinToGeomety(String jsonString) { final OperatorImportFromGeoJson op = (OperatorImportFromGeoJson) OperatorFactoryLocal .getInstance().getOperator(Operator.Type.ImportFromGeoJson); final MapOGCStructure structure = op.executeOGC(WktImportFlags.wktImportDefaults, jsonString, null); return OGCGeometry.createFromOGCStructure(structure.m_ogcStructure, structure.m_spatialReference); }
Example #11
Source File: GeographyTest.java From barefoot with Apache License 2.0 | 5 votes |
@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)"); } }
Example #12
Source File: RouteTest.java From barefoot with Apache License 2.0 | 4 votes |
@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)); } }
Example #13
Source File: ESRI.java From sis with Apache License 2.0 | 4 votes |
/** * Parses the given WKT. */ @Override public Object parseWKT(final String wkt) { return OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.Unknown, wkt, null); }
Example #14
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_GeomFromText(String s, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(s, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); return bind(g, srid); }
Example #15
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_LineFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Line); return bind(g, srid); }
Example #16
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_MPointFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.MultiPoint); return bind(g, srid); }
Example #17
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_PointFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Point); return bind(g, srid); }
Example #18
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_PolyFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Polygon); return bind(g, srid); }
Example #19
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_MLineFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); // NOTE: there is no Geometry.Type.MultiLine return bind(g, srid); }
Example #20
Source File: GeoFunctions.java From calcite with Apache License 2.0 | 4 votes |
public static Geom ST_MPolyFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); // NOTE: there is no Geometry.Type.MultiPolygon return bind(g, srid); }
Example #21
Source File: GeoFunctions.java From Bats with Apache License 2.0 | 4 votes |
public static Geom ST_GeomFromText(String s, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(s, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); return bind(g, srid); }
Example #22
Source File: GeographyTest.java From barefoot with Apache License 2.0 | 4 votes |
@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); } }
Example #23
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_MPolyFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); // NOTE: there is no Geometry.Type.MultiPolygon return bind(g, srid); }
Example #24
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_MLineFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); // NOTE: there is no Geometry.Type.MultiLine return bind(g, srid); }
Example #25
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_PolyFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Polygon); return bind(g, srid); }
Example #26
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_PointFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Point); return bind(g, srid); }
Example #27
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_MPointFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.MultiPoint); return bind(g, srid); }
Example #28
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_LineFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Line); return bind(g, srid); }
Example #29
Source File: GeoFunctions.java From Quicksql with MIT License | 4 votes |
public static Geom ST_GeomFromText(String s, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(s, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); return bind(g, srid); }
Example #30
Source File: GeoFunctions.java From Bats with Apache License 2.0 | 4 votes |
public static Geom ST_MPolyFromText(String wkt, int srid) { final Geometry g = GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults, Geometry.Type.Unknown); // NOTE: there is no Geometry.Type.MultiPolygon return bind(g, srid); }