Package org.geotools.data.shapefile.shp.ShapefileReader

Examples of org.geotools.data.shapefile.shp.ShapefileReader.Record


            next = goodRecs.next();

            Long l = (Long) next.getValue(1);
            shp.goTo((int) l.longValue());

            Record record = shp.nextRecord();

            // read the geometry, so that we can decide if this row is to be skipped or not
            Geometry geometry = getGeometry(record);
            if (geometry == SKIP) {
                continue;
            }

            // read the dbf only if the geometry was not skipped
            Row row;
            if (dbf != null) {
                ((IndexedDbaseFileReader) dbf).goTo(record.number);
                row = dbf.readRow();
            } else {
                row = null;
            }

            nextFeature = buildFeature(record.number, geometry, row, record.envelope());
        }

        return nextFeature != null;
    }
View Full Code Here


    }

    @Override
    public boolean hasNext() throws IOException {
        while (nextFeature == null && filesHaveMore()) {
            Record record = shp.nextRecord();

            Geometry geometry = getGeometry(record);
            if (geometry != SKIP) {
                // also grab the dbf row
                Row row;
                if (dbf != null) {
                    row = dbf.readRow();
                    if(row.isDeleted()) {
                        continue;
                    }
                } else {
                    row = null;
                }

                nextFeature = buildFeature(record.number, geometry, row, record.envelope());
            } else {
                if (dbf != null) {
                    dbf.skip();
                }
            }
View Full Code Here

        Envelope bounds = new Envelope(header.minX(), header.maxX(), header
                .minY(), header.maxY());

        tree = new QuadTree(numRecs, max, bounds, shpIndex);
        try {
            Record rec = null;

            while (reader.hasNext()) {
                rec = reader.nextRecord();
                tree.insert(cnt++, new Envelope(rec.minX, rec.maxX, rec.minY,
                        rec.maxY));
View Full Code Here

           
            for (int i = 0; i < numShapesId; i++) {
                final int shapeId = shapeIds[i];
                int offset = index.getOffsetInBytes(shapeId);
                reader.goTo(offset);
                Record rec = reader.nextRecord();
                Envelope env = new Envelope(rec.minX, rec.maxX, rec.minY, rec.maxY);
                tree.insert(node, shapeId, env, extraLevels);
            }
        }
       
        // pack the arrays to use less memory (the optimization often makes the tree grow)
        node.pack();
       
        // recurse
        for (int i = 0; i < node.getNumSubNodes(); i++) {
            optimizeTree(tree, node.getSubNode(i), level + 1, reader, index);
        }
       
        // prune empty subnodes
        for (int i = 0; i < node.getNumSubNodes();) {
            Node child = node.getSubNode(i);
            if(child != null && child.getNumShapeIds() == 0 && child.getNumSubNodes() == 0) {
                // empty child, we don't need it, clean it up
                node.removeSubNode(child);
            } else {
                i++;
            }
        }
       
        // handle degenerate chains, we pop up the nodes to the top by keeping
        // their shape ids _and_ their bounds (as it's the only area that has something)
        if(node.getNumSubNodes() == 1 && node.getNumShapeIds() == 0) {
            Node subnode = node.getSubNode(0);
            node.clearSubNodes();
            node.setShapesId(subnode);
            node.setBounds(subnode.getBounds());
            for (int i = 0; i < subnode.getNumSubNodes(); i++) {
                node.addSubNode(subnode.getSubNode(i));
            }
        } else {
            // limit this node area to the effective child area
            Envelope bounds = new Envelope();
            if(node.getNumShapeIds() > 0) {
                int[] shapeIds  = node.getShapesId();
                for (int i = 0; i < shapeIds.length; i++) {
                    final int shapeId = shapeIds[i];
                    int offset = index.getOffsetInBytes(shapeId);
                    reader.goTo(offset);
                    Record rec = reader.nextRecord();
                    Envelope env = new Envelope(rec.minX, rec.maxX, rec.minY, rec.maxY);
                    bounds.expandToInclude(env);
                }
            }
            if(node.getNumSubNodes() > 0) {
View Full Code Here

          tx.close();
        }
       
        monitor.begin(dbaseFileHeader.getNumRecords());
        try {
          Record record;
          Geometry geometry;
          Object[] values;
                    ArrayList<Object> fields = new ArrayList<Object>();
          int recordCounter = 0;
          int filterCounter = 0;
          while (shpReader.hasNext() && dbfReader.hasNext()) {
            tx = database.beginTx();
            try {
              int committedSinceLastNotification = 0;
              for (int i = 0; i < commitInterval; i++) {
                if (shpReader.hasNext() && dbfReader.hasNext()) {
                  record = shpReader.nextRecord();
                  recordCounter++;
                  committedSinceLastNotification++;
                  try {
                                        fields.clear();
                    geometry = (Geometry) record.shape();
                    if (filterEnvelope == null || filterEnvelope.intersects(geometry.getEnvelopeInternal())) {
                      values = dbfReader.readEntry();
                      fields.add(recordCounter);
                      Collections.addAll(fields, values);
                      if (geometry.isEmpty()) {
View Full Code Here

TOP

Related Classes of org.geotools.data.shapefile.shp.ShapefileReader.Record

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.