Package com.vividsolutions.jts.io

Examples of com.vividsolutions.jts.io.WKTReader


    public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx)
            throws SQLException, IOException {
        String wkt = rs.getString( column );
        if ( wkt != null ) {
            try {
                return new WKTReader().read( wkt ).getEnvelopeInternal();
            }
            catch (ParseException e) {
                throw (IOException) new IOException("Error decoding envelope bounds").initCause( e );
            }
        }


        Calendar cal = Calendar.getInstance();
        cal.set(2004, 06, value, 0, 0, 0);
        build.add(cal);

        WKTReader reader = new WKTReader();
        build.add(reader.read("POINT(1 1)"));

        SimpleFeature newFeature = build.buildFeature(null);
        SimpleFeatureCollection newFeatures = DataUtilities.collection(newFeature);

        List<FeatureId> newFids = featureStore1.addFeatures(newFeatures);

        }
    }

    @Test
    public void testUpdateAdjacentPolygonsTransaction() throws Exception {
        final WKTReader reader = new WKTReader();
        final Polygon p1 = (Polygon) reader
                .read("POLYGON((-10 -10, -10 10, 0 10, 0 -10, -10 -10))");
        final Polygon p2 = (Polygon) reader.read("POLYGON((0 -10, 0 10, 10 10, 10 -10, 0 -10))");

        final Polygon modif1 = (Polygon) reader
                .read("POLYGON ((-10 -10, -10 10, 5 10, -5 -10, -10 -10))");
        final Polygon modif2 = (Polygon) reader
                .read("POLYGON ((-5 -10, 5 10, 10 10, 10 -10, -5 -10))");

        final String typeName = testData.getTempTableName(); // "SDE.CJ_TST_1";
        final ArcSDEDataStore dataStore = testData.getDataStore();
        // String[] typeNames = dataStore.getTypeNames();

            final SimpleFeatureType schema = store.getSchema();

            final int initialCount = store.getCount(Query.ALL);
            assertEquals(0, initialCount);

            final WKTReader reader = new WKTReader();
            Object[] content = new Object[2];
            SimpleFeature feature;
            SimpleFeatureCollection collection;
            int count;

            content[0] = "Feature name 1";
            content[1] = reader.read("POINT (10 10)");
            feature = SimpleFeatureBuilder.build(schema, content, (String) null);
            collection = DataUtilities.collection(feature);

            store.addFeatures(collection);

            count = store.getCount(Query.ALL);
            assertEquals(1, count);
            assertEquals(0, source.getCount(Query.ALL));

            {
                SimpleFeatureIterator features = store.getFeatures().features();
                SimpleFeature f = features.next();
                features.close();
                Object obj = f.getDefaultGeometry();
                assertTrue(obj instanceof Point);
                Point p = (Point) obj;
                double x = p.getX();
                double y = p.getY();
                assertEquals(10D, x, 1E-5);
                assertEquals(10D, y, 1E-5);
            }

            transaction.commit();
            assertEquals(1, source.getCount(Query.ALL));

            content[0] = "Feature name 2";
            content[1] = reader.read("POINT (2 2)");
            feature = SimpleFeatureBuilder.build(schema, content, (String) null);
            collection = DataUtilities.collection(feature);

            store.addFeatures(collection);

     *
     * @throws ParseException
     */
    private void insertData(final SeLayer layer, final ISession session,
            final SeColumnDefinition[] colDefs) throws Exception {
        WKTReader reader = new WKTReader();
        Geometry[] geoms = new Geometry[8];
        geoms[0] = reader.read("POINT(0 0)");
        geoms[1] = reader.read("MULTIPOINT(0 0, 170 0)");
        geoms[2] = reader.read("LINESTRING(0 0, 170 80)");
        geoms[3] = reader.read("MULTILINESTRING((-170 -80, 170 80), (-170 80, 170 -80))");
        geoms[4] = reader.read("POLYGON((-10 -10, -10 10, 10 10, 10 -10, -10 -10))");
        geoms[5] = reader
                .read("MULTIPOLYGON( ((-1 -1, -1 1, 1 1, 1 -1, -1 -1)), ((-170 -80, -170 -70, -160 -70, -160 -80, -170 -80)) )");
        geoms[6] = reader.read("POINT EMPTY");
        geoms[7] = null;

        insertData(geoms, layer, session);
    }

        runTestWithFilter(ft, filter, empty, null);
    }

    private Geometry geom(String wkt) {
        try {
            return new WKTReader().read(wkt);
        } catch (ParseException e) {
            throw new IllegalArgumentException(e);
        }
    }

public class LineStringCursorTest {

    @Test
    public void testMaxAngle() throws Exception {
        LineString ls = (LineString) new WKTReader().read("LINESTRING(20 0, 10 1, 0 0)");
        LineStringCursor cursor = new LineStringCursor(ls);
        double maxAngle = cursor.getMaxAngleChange(0, ls.getLength());
        assertTrue(maxAngle < 11.5);
    }

        return fb.buildFeature(null);
    }

    private static Geometry geometry(String wkt) {
        try {
            return new WKTReader().read(wkt);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

     */
    protected Geometry readGeometry(final String wktResource)
            throws IOException {
        final BufferedReader stream = TestData.openReader("wkt/" + wktResource
                + ".wkt");
        final WKTReader reader = new WKTReader();
        final Geometry geom;
        try {
            geom = reader.read(stream);
        } catch (ParseException pe) {
            IOException e = new IOException("parsing error in resource "
                    + wktResource);
            e.initCause(pe);
            throw e;

        try {
          reader=new FileReader(footprintSummaryFile);
            BufferedReader bReader = new BufferedReader(reader);
            String footprint;

            final WKTReader geometryReader = new WKTReader();
            while ((footprint = bReader.readLine()) != null) {
                String fpt[] = footprint.split("=");
                if (fpt.length == 2) {
                  // parse the geometry
                    footprintsIDGeometryMap.put(fpt[0], geometryReader.read(fpt[1]));
                }
            }
            bReader.close();
        } catch (IOException e) {
            if (LOGGER.isLoggable(Level.FINE)) {

TOP

Related Classes of com.vividsolutions.jts.io.WKTReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.