@Override public String resolve(double x, double y) { System.out.println("x="+x+", y="+y); FeatureIterator<Feature> iterator = collection.features(); while( iterator.hasNext() ){ SimpleFeature feature = (SimpleFeature) iterator.next(); Geometry geom = (Geometry) feature.getDefaultGeometry(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); Coordinate coord = new Coordinate(x, y); Point point = geometryFactory.createPoint(coord); //System.out.println("checking "+point.toString()); if(geom.contains(point)) { return feature.getAttribute(this.nameField).toString(); } } return null; }
/** * Returns a set of all available implementations for the {@link CoordinateSequenceFactory} * interface. * * @return Set of available coordinate sequence factory implementations. */ public static synchronized Set getCoordinateSequenceFactories() { return JTSFactoryFinder.getCoordinateSequenceFactories(); }
/** * Creates a new instance of the specified factory using the specified hints. * * @param category The category to instantiate. * @param implementation The factory class to instantiate. * @param hints The implementation hints. * @return The factory. * @throws FactoryRegistryException if the factory creation failed. */ protected Object createServiceProvider( final Class category, final Class implementation, final Hints hints) throws FactoryRegistryException { if (GeometryFactory.class.isAssignableFrom(category) && GeometryFactory.class.equals(implementation)) { return new GeometryFactory( getPrecisionModel(hints), getSRID(hints), getCoordinateSequenceFactory(hints)); } return super.createServiceProvider(category, implementation, hints); }
/** * Returns the first implementation of {@link CoordinateSequenceFactory} matching the specified * hints. If no implementation matches, a new one is created if possible or an exception is * thrown otherwise. * * @param hints An optional map of hints, or {@code null} if none. * @return The first coordinate sequence factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link CoordinateSequenceFactory} interface and the given hints. */ public static synchronized CoordinateSequenceFactory getCoordinateSequenceFactory(Hints hints) throws FactoryRegistryException { return JTSFactoryFinder.getCoordinateSequenceFactory(hints); }
/** * Returns the first implementation of {@link CoordinateSequenceFactory} matching the specified * hints. If no implementation matches, a new one is created if possible or an exception is * thrown otherwise. * * @param hints An optional map of hints, or {@code null} if none. * @return The first coordinate sequence factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link CoordinateSequenceFactory} interface and the given hints. */ public static synchronized CoordinateSequenceFactory getCoordinateSequenceFactory(Hints hints) throws FactoryRegistryException { return JTSFactoryFinder.getCoordinateSequenceFactory(hints); }
MathTransform toMeters = CRS.findMathTransform(wgs, crs, false); MathTransform fromMeters = CRS.findMathTransform(crs, wgs, false); GeometryFactory geomf = JTSFactoryFinder.getGeometryFactory();
/** * Creates a new instance of the specified factory using the specified hints. * * @param category The category to instantiate. * @param implementation The factory class to instantiate. * @param hints The implementation hints. * @return The factory. * @throws FactoryRegistryException if the factory creation failed. */ protected Object createServiceProvider(final Class category, final Class implementation, final Hints hints) throws FactoryRegistryException { if (GeometryFactory.class.isAssignableFrom(category) && GeometryFactory.class.equals(implementation)) { return new GeometryFactory(getPrecisionModel(hints), getSRID(hints), getCoordinateSequenceFactory(hints)); } return super.createServiceProvider(category, implementation, hints); }
/** * Returns a set of all available implementations for the {@link CoordinateSequenceFactory} * interface. * * @return Set of available coordinate sequence factory implementations. */ public static synchronized Set getCoordinateSequenceFactories() { return JTSFactoryFinder.getCoordinateSequenceFactories(); }
/** Creates a reader that creates objects using the default {@link GeometryFactory}. */ public WKTReader2() { this(JTSFactoryFinder.getGeometryFactory(null)); }
/** * Returns the first implementation of {@link GeometryFactory}, a new one is created if possible * or an exception is thrown otherwise. * * @return The first geometry factory available on the classpath * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} category. */ public static synchronized GeometryFactory getGeometryFactory() throws FactoryRegistryException { return getGeometryFactory(null); } /**
/** * Returns the first implementation of {@link GeometryFactory} matching the specified hints. If * no implementation matches, a new one is created if possible or an exception is thrown * otherwise. * * <p>Hints that may be understood includes {@link Hints#JTS_COORDINATE_SEQUENCE_FACTORY * JTS_COORDINATE_SEQUENCE_FACTORY}, {@link Hints#JTS_PRECISION_MODEL JTS_PRECISION_MODEL} and * {@link Hints#JTS_SRID JTS_SRID}. * * @param hints An optional map of hints, or {@code null} if none. * @return The first geometry factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} category and the given hints. */ public static synchronized GeometryFactory getGeometryFactory(Hints hints) throws FactoryRegistryException { return JTSFactoryFinder.getGeometryFactory(hints); }
/** Creates a reader that creates objects using the default {@link GeometryFactory}. */ public WKTReader2(double tolerance) { this(new CurvedGeometryFactory(JTSFactoryFinder.getGeometryFactory(null), tolerance)); }
@Test public void testJTSFactory() { GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null); assertNotNull(gf); }
private static GeometryFactory getGeometryFactory() { if (geometryFactory != null) { return geometryFactory; } else { return (geometryFactory = JTSFactoryFinder.getGeometryFactory(null)); } }
/** * Creates a reader that creates objects using the default {@link GeometryFactory}. */ public WKTReader2() { this(JTSFactoryFinder.getGeometryFactory( null )); }
/** * Returns the first implementation of {@link GeometryFactory}, a new one is created if * possible or an exception is thrown otherwise. * * @return The first geometry factory available on the classpath * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} category. */ public static synchronized GeometryFactory getGeometryFactory() throws FactoryRegistryException { return getGeometryFactory(null); } /**
public GeobufGeometry(int precision, int dimension) { this(precision, dimension, JTSFactoryFinder.getGeometryFactory(null)); }
public GeobufGeometry() { this(6, 2, JTSFactoryFinder.getGeometryFactory(null)); }
/** * Returns the first implementation of {@link GeometryFactory} matching the specified hints. * If no implementation matches, a new one is created if possible or an exception is thrown * otherwise. * <p> * Hints that may be understood includes * {@link Hints#JTS_COORDINATE_SEQUENCE_FACTORY JTS_COORDINATE_SEQUENCE_FACTORY}, * {@link Hints#JTS_PRECISION_MODEL JTS_PRECISION_MODEL} and * {@link Hints#JTS_SRID JTS_SRID}. * * @param hints An optional map of hints, or {@code null} if none. * @return The first geometry factory that matches the supplied hints. * @throws FactoryRegistryException if no implementation was found or can be created for the * {@link GeometryFactory} category and the given hints. */ public static synchronized GeometryFactory getGeometryFactory(Hints hints) throws FactoryRegistryException { return JTSFactoryFinder.getGeometryFactory(hints); }
public void testGraphicLegendRotation() throws Exception { FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(); // Load image directly from file, for comparison with painter output final URL imageURL = TestData.getResource(this, "icon64.png"); final BufferedImage testImage = ImageIO.read(imageURL); final int width = testImage.getWidth(); final int height = testImage.getHeight(); // Get graphic legend from style final Style style = RendererBaseTest.loadStyle(this, "testGraphicLegend.sld"); final Rule rule = style.featureTypeStyles().get(0).rules().get(0); final GraphicLegend legend = (GraphicLegend) rule.getLegend(); // Set rotation to 45 degrees legend.setRotation(ff.literal(45.0)); // Paint legend using StyledShapePainter final Point point = gf.createPoint(new Coordinate(width / 2, height / 2)); final LiteShape2 shape = new LiteShape2(point, null, null, false); int imageType = testImage.getType(); if (imageType == BufferedImage.TYPE_CUSTOM) { imageType = BufferedImage.TYPE_INT_RGB; } final BufferedImage paintedImage = new BufferedImage(width, height, imageType); final Graphics2D graphics = paintedImage.createGraphics(); final StyledShapePainter painter = new StyledShapePainter(); painter.paint(graphics, shape, legend, 1, false); graphics.dispose(); // Ensure painted legend does not match image from file Assert.assertFalse(imagesIdentical(paintedImage, testImage)); }