Examples of ShpFiles


Examples of org.geotools.data.shapefile.files.ShpFiles

    }

    @Test
    public void testSkippingRecords() throws Exception {
        final URL url = TestData.url(STATEPOP);
        final ShapefileReader r = new ShapefileReader(new ShpFiles(url), false,
                false, new GeometryFactory());
        try {
            int idx = 0;
            while (r.hasNext()) {
                idx++;
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }

    @Test
    public void testShapefileReaderRecord() throws Exception {
        final URL c1 = TestData.url(STATEPOP);
        ShapefileReader reader = new ShapefileReader(new ShpFiles(c1), false,
                false, new GeometryFactory());
        URL c2;
        try {
            ArrayList offsets = new ArrayList();
            while (reader.hasNext()) {
                ShapefileReader.Record record = reader.nextRecord();
                offsets.add(new Integer(record.offset()));
                Geometry geom = (Geometry) record.shape();
                assertEquals(new Envelope(record.minX, record.maxX,
                        record.minY, record.maxY), geom.getEnvelopeInternal());
                record.toString();
            }
            copyShapefiles(STATEPOP);
            reader.close();
            c2 = TestData.url(TestCaseSupport.class, STATEPOP);
            reader = new ShapefileReader(new ShpFiles(c2), false, false, new GeometryFactory());
            for (int i = 0, ii = offsets.size(); i < ii; i++) {
                reader.shapeAt(((Integer) offsets.get(i)).intValue());
            }
        } finally {
            reader.close();
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    writer.close();
    transaction.commit();
    ds.dispose();

    // Read the same file and check the geometry is null
    ShpFiles shpFiles = new ShpFiles(shpUrl);
    ShapefileReader reader = new ShapefileReader(shpFiles, false, true,
        new GeometryFactory(), false);
    try {
      assertTrue(reader.hasNext());
      assertTrue(reader.nextRecord().shape() == null);
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }
  }

    protected void loadShapes(String resource, int expected) throws Exception {
        final URL url = TestData.url(resource);
        ShapefileReader reader = new ShapefileReader(new ShpFiles(url), false,
                false, new GeometryFactory());
        int cnt = 0;
        try {
            while (reader.hasNext()) {
                reader.nextRecord().shape();
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }

    @Test
    public void testReadingSparse() throws IOException {
        File file = TestData.file(TestCaseSupport.class, "sparse/sparse.shp");
        ShapefileReader reader = new ShapefileReader(new ShpFiles(file), false, false, new GeometryFactory());
        int cnt = 0;
        try {
            while (reader.hasNext()) {
                reader.nextRecord().shape();
                cnt++;
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    }
 
    protected void loadMemoryMapped(String resource, int expected)
            throws Exception {
        final URL url = TestData.url(resource);
        ShapefileReader reader = new ShapefileReader(new ShpFiles(url), false,
                false, new GeometryFactory());
        int cnt = 0;
        try {
            while (reader.hasNext()) {
                reader.nextRecord().shape();
View Full Code Here

Examples of org.geotools.data.shapefile.files.ShpFiles

    /*
     * Test method for 'org.geotools.index.fid.FidIndexer.generate(URL)'
     */
    @Test
    public void testGenerate() throws Exception {
        ShpFiles shpFiles = new ShpFiles(backshp.toURI().toURL());
        FidIndexer.generate(shpFiles);

        ShapefileDataStore ds = new ShapefileDataStore(DataUtilities.fileToURL(backshp));

        SimpleFeatureSource fs = ds.getFeatureSource();
        int features = fs.getCount(Query.ALL);

        IndexedFidReader reader = new IndexedFidReader(shpFiles);

        try {
            assertEquals(features, reader.getCount());

            int i = 1;

            while (reader.hasNext()) {
                assertEquals(shpFiles.getTypeName() + "." + i, reader.next());
                assertEquals(shpFiles.getTypeName() + "." + i, i - 1, reader.currentSHXIndex());
                i++;
            }

            assertEquals(features, i - 1);
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.