Package org.geotools.data.shapefile.files

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


    ShpXmlFileReader reader;

    @Before
    public void setUp() throws Exception {
        URL example = TestData.url(TestCaseSupport.class, "example.shp.xml");
        ShpFiles shpFiles = new ShpFiles(example);

        reader = new ShpXmlFileReader(shpFiles);
    }
View Full Code Here


                if (!args[i].toLowerCase().endsWith(".shp")) {
                    System.out.println("File extension must be '.shp'");
                    System.exit(1);
                }

                idx.setShapeFileName(new ShpFiles(args[i]));
            }
        }

        try {
            System.out.print("Indexing ");
View Full Code Here

    public boolean IsRandomAccessEnabled() {
        return this.randomAccessEnabled;
    }

    public static void main(String[] args) throws Exception {
        IndexedDbaseFileReader reader = new IndexedDbaseFileReader(new ShpFiles(args[0]), false);
        System.out.println(reader.getHeader());
        int r = 0;
        while (reader.hasNext()) {
            System.out.println(++r + "," + java.util.Arrays.asList(reader.readEntry()));
        }
View Full Code Here

        }
        return new String(chars);
    }

    public static void main(final String[] args) throws Exception {
        final DbaseFileReader reader = new DbaseFileReader(new ShpFiles(args[0]),
                false, Charset.forName("ISO-8859-1"), null);
        System.out.println(reader.getHeader());
        int r = 0;
        while (reader.hasNext()) {
            System.out.println(++r + ","
View Full Code Here

        Map<ShpFileType, File> files1 = ShpFilesTest.createFiles("Files1",
                ShpFileType.values(), false);
        Map<ShpFileType, File> files2 = ShpFilesTest.createFiles("Files2",
            ShpFileType.values(), false);

        shpFiles1 = new ShpFiles(files1.get(SHP));
        shpFiles2 = new ShpFiles(files2.get(SHP));
    }
View Full Code Here

        shpFiles2 = new ShpFiles(files2.get(SHP));
    }

    @Test
    public void testReplaceOriginal() throws Exception {
        ShpFiles files1 = shpFiles1;
        ShpFileType type = PRJ;
        StorageFile storagePRJ1 = files1.getStorageFile(type);
        File original = storagePRJ1.getFile();
       
        try {
          String writtenToStorageFile = "Copy";
 
          writeData(storagePRJ1, writtenToStorageFile);
 
          storagePRJ1.replaceOriginal();
          assertEquals(0, files1.numberOfLocks());
 
          assertCorrectData(files1, type, writtenToStorageFile);
        } catch(Exception e) {
          storagePRJ1.getFile().delete();
          original.delete();
View Full Code Here

        backprj =  sibling(backshp, "prj");
        backqix =  sibling(backshp, "qix");

        fixFile =  sibling(backshp, "fix");

        shpFiles = new ShpFiles(backshx);
    }
View Full Code Here

        copyShapefiles(STATEPOP);
        copyShapefiles(STATEPOP_IDX);
        final URL url1 = TestData.url(STATEPOP); // Backed by InputStream
        final URL url2 = TestData.url(TestCaseSupport.class, STATEPOP); // Backed by File
        final URL url3 = TestData.url(TestCaseSupport.class, STATEPOP_IDX);
        final ShapefileReader reader1 = new ShapefileReader(new ShpFiles(url1),
                false, false, new GeometryFactory());
        final ShapefileReader reader2 = new ShapefileReader(new ShpFiles(url2),
                false, false, new GeometryFactory());
        final IndexFile index = new IndexFile(new ShpFiles(url3), false);
        try {
            for (int i = 0; i < index.getRecordCount(); i++) {
                if (reader1.hasNext()) {

                    Geometry g1 = (Geometry) reader1.nextRecord().shape();
View Full Code Here

    }

    @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

    }

    @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

TOP

Related Classes of org.geotools.data.shapefile.files.ShpFiles

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.