/** * Casts the provided geometry factory to a curved one if possible, or wraps it into one with * infinite tolerance (the linearization will happen using the default base segments number set * in {@link CircularArc} * * @param gf * @return */ private static CurvedGeometryFactory getCurvedGeometryFactory(GeometryFactory gf) { CurvedGeometryFactory curvedFactory; if (gf instanceof CurvedGeometryFactory) { curvedFactory = (CurvedGeometryFactory) gf; } else { curvedFactory = new CurvedGeometryFactory(gf, Double.MAX_VALUE); } return curvedFactory; }
/** * Casts the provided geometry factory to a curved one if possible, or wraps it into one with * infinite tolerance (the linearization will happen using the default base segments number set * in {@link CircularArc} * * @param gf * @return */ private CurvedGeometryFactory getCurvedGeometryFactory(GeometryFactory gf) { CurvedGeometryFactory curvedFactory; if (gf instanceof CurvedGeometryFactory) { curvedFactory = (CurvedGeometryFactory) gf; } else { curvedFactory = new CurvedGeometryFactory(gf, Double.MAX_VALUE); } return curvedFactory; } }
/** * Creates a reader that creates objects using the given {@link GeometryFactory}. * * @param geometryFactory the factory used to create <code>Geometry</code>s. */ public WKTReader2(GeometryFactory geometryFactory) { if (geometryFactory instanceof CurvedGeometryFactory) { this.geometryFactory = (CurvedGeometryFactory) geometryFactory; } else { this.geometryFactory = new CurvedGeometryFactory(geometryFactory, Double.MAX_VALUE); } precisionModel = geometryFactory.getPrecisionModel(); }
/** Creates a reader that creates objects using the default {@link GeometryFactory}. */ public WKTReader2(double tolerance) { this(new CurvedGeometryFactory(JTSFactoryFinder.getGeometryFactory(null), tolerance)); }
/** * Extracts a {@link CurvedGeometryFactory} from the provided geometry, either by just returning * the one that is held by the geometry, if consistent with its tolerance, or by creating a new * one * * @param curved * @return */ public static CurvedGeometryFactory getFactory(CurvedGeometry<?> curved) { GeometryFactory factory = ((Geometry) curved).getFactory(); if (factory instanceof CurvedGeometryFactory) { CurvedGeometryFactory cf = (CurvedGeometryFactory) factory; if (cf.getTolerance() == curved.getTolerance()) { return cf; } } return new CurvedGeometryFactory(factory, curved.getTolerance()); } }
@Override protected void setUp() throws Exception { GMLConfiguration configuration = new GMLConfiguration(true); configuration.setGeometryFactory(new CurvedGeometryFactory(TOLERANCE)); this.gml = configuration; } }
protected void setUp() throws Exception { GMLConfiguration configuration = new GMLConfiguration(true); configuration.setGeometryFactory(new CurvedGeometryFactory(TOLERANCE)); this.gml = configuration; }
/** * Returns a curved geometry factory given the linearization constraints, the original factory, * and a coordinate sequence representing the control points of a curved geometry * * @param arcParameters * @param gFactory * @param cs * @return */ public static CurvedGeometryFactory getCurvedGeometryFactory( ArcParameters arcParameters, GeometryFactory gFactory, CoordinateSequence cs) { CurvedGeometryFactory factory; if (gFactory instanceof CurvedGeometryFactory) { factory = (CurvedGeometryFactory) gFactory; } else if (arcParameters != null && arcParameters.getLinearizationTolerance() != null) { double tolerance = Double.MAX_VALUE; if (cs != null) { CircularArc arc = CurvedGeometries.getArc(cs, 0); Circle c = new Circle(arc.getCenter(), arc.getRadius()); tolerance = arcParameters.getLinearizationTolerance().getTolerance(c); } factory = new CurvedGeometryFactory(gFactory, tolerance); } else { factory = new CurvedGeometryFactory(gFactory, Double.MAX_VALUE); } return factory; } }
public static LineString compoundCurve() { CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); return compound; }
geometryFactory = new CurvedGeometryFactory(geometryFactory, linearizationTolerance);
@Test public void testFlipAxisOnCurved() throws Exception { CircularString cs = (CircularString) new CurvedGeometryFactory(0.1).createCurvedGeometry(2, 0, 1, 1, 2, 2, 1); GeometryCoordinateSequenceTransformer transformer = new GeometryCoordinateSequenceTransformer(); CoordinateReferenceSystem crsLatLon = CRS.decode("urn:ogc:def:crs:EPSG:4326"); CoordinateReferenceSystem crsLonLat = CRS.decode("EPSG:4326", true); transformer.setCoordinateReferenceSystem(crsLatLon); MathTransform trans = CRS.findMathTransform(crsLonLat, crsLatLon); transformer.setMathTransform(trans); Geometry transformed = transformer.transform(cs); assertTrue(transformed instanceof CircularString); CircularString tcs = (CircularString) transformed; assertArrayEquals(new double[] {1, 0, 2, 1, 1, 2}, tcs.getControlPoints(), 0d); }
@Test public void testFullTransformOnCurved() throws Exception { CircularString cs = (CircularString) new CurvedGeometryFactory(0.1).createCurvedGeometry(2, 0, 1, 1, 2, 2, 1); GeometryCoordinateSequenceTransformer transformer = new GeometryCoordinateSequenceTransformer(); CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857"); CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326", true); transformer.setCoordinateReferenceSystem(targetCRS); MathTransform trans = CRS.findMathTransform(sourceCRS, targetCRS); transformer.setMathTransform(trans); Geometry transformed = transformer.transform(cs); assertFalse(transformed instanceof CircularString); LineString ls = (LineString) transformed; assertTrue(ls.getCoordinateSequence().size() > 3); }
public void testEncodeCurve() throws Exception { LineString curve = new CurvedGeometryFactory(0.1) .createCurvedGeometry( new LiteCoordinateSequence( new double[] {1, 1, 2, 2, 3, 1, 5, 5, 7, 3})); Document dom = encode(curve, GML.geometryMember); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); String basePath = "/gml:geometryMember/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath + "/gml:posList", dom)); }
public void testEncodeSimple() throws Exception { LineString curve = new CurvedGeometryFactory(0.1) .createCurvedGeometry( new LiteCoordinateSequence( new double[] {1, 1, 2, 2, 3, 1, 5, 5, 7, 3})); Document dom = encode(curve, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); String basePath = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath + "/gml:posList", dom)); }
public void testEncodeSimple() throws Exception { LineString curve = new CurvedGeometryFactory(0.1) .createCurvedGeometry( new LiteCoordinateSequence( new double[] {1, 1, 2, 2, 3, 1, 5, 5, 7, 3})); Document dom = encode(curve, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); String basePath = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath + "/gml:posList", dom)); }
public void testEncodeCompound() throws Exception { // create a compound curve CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); // encode Document dom = encode(compound, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); // the curve portion String basePath1 = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath1 + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath1 + "/gml:posList", dom)); // the straight portion String basePath2 = "/gml:curveProperty/gml:Curve/gml:segments/gml:LineStringSegment"; assertEquals( 1, xpath.getMatchingNodes(basePath2 + "[@interpolation='linear']", dom).getLength()); assertEquals("7 3 10 15", xpath.evaluate(basePath2 + "/gml:posList", dom)); } }
public void testEncodeCompound() throws Exception { // create a compound curve CurvedGeometryFactory factory = new CurvedGeometryFactory(0.1); LineString curve = factory.createCurvedGeometry( new LiteCoordinateSequence(1, 1, 2, 2, 3, 1, 5, 5, 7, 3)); LineString straight = factory.createLineString(new LiteCoordinateSequence(7, 3, 10, 15)); LineString compound = factory.createCurvedGeometry(curve, straight); // encode Document dom = encode(compound, GML.curveProperty); // print(dom); XpathEngine xpath = XMLUnit.newXpathEngine(); // the curve portion String basePath1 = "/gml:curveProperty/gml:Curve/gml:segments/gml:ArcString"; assertEquals( 1, xpath.getMatchingNodes(basePath1 + "[@interpolation='circularArc3Points']", dom) .getLength()); assertEquals("1 1 2 2 3 1 5 5 7 3", xpath.evaluate(basePath1 + "/gml:posList", dom)); // the straight portion String basePath2 = "/gml:curveProperty/gml:Curve/gml:segments/gml:LineStringSegment"; assertEquals( 1, xpath.getMatchingNodes(basePath2 + "[@interpolation='linear']", dom).getLength()); assertEquals("7 3 10 15", xpath.evaluate(basePath2 + "/gml:posList", dom)); } }
WFSConfiguration() { // OGC and OWS add two extra GML configurations in the mix, make sure to configure them // all with a geomtetry factory supporting curves CurvedGeometryFactory gf = new CurvedGeometryFactory(Double.MAX_VALUE); for (Object configuration : allDependencies()) { if (configuration instanceof GMLConfiguration) { GMLConfiguration gml = (GMLConfiguration) configuration; gml.setGeometryFactory(gf); } } }
public WFSConfiguration( GeoServer geoServer, FeatureTypeSchemaBuilder schemaBuilder, final WFS wfs) { super(wfs); this.catalog = geoServer.getCatalog(); this.schemaBuilder = schemaBuilder; addDependency(new OGCConfiguration()); addDependency(new OWSConfiguration()); addDependency(new GMLConfiguration()); // OGC and OWS add two extra GML configurations in the mix, make sure to configure them // all... CurvedGeometryFactory gf = new CurvedGeometryFactory(Double.MAX_VALUE); for (Object configuration : allDependencies()) { if (configuration instanceof GMLConfiguration) { GMLConfiguration gml = (GMLConfiguration) configuration; gml.setGeometryFactory(gf); } } }
protected void configureContext(MutablePicoContainer context) { super.configureContext(context); context.registerComponentInstance(WfsFactory.eINSTANCE); context.registerComponentInstance(new WFSHandlerFactory(catalog, schemaBuilder)); context.registerComponentInstance(catalog); context.registerComponentImplementation(PropertyTypePropertyExtractor.class); context.registerComponentInstance(getSrsSyntax()); // seed the cache with entries from the catalog context.registerComponentInstance( FeatureTypeCache.class, new CatalogFeatureTypeCache(getCatalog())); context.registerComponentInstance(new CurvedGeometryFactory(Double.MAX_VALUE)); }