Package com.esri.sde.sdk.client

Examples of com.esri.sde.sdk.client.SeShape


     */
    public Object read(final int index) throws IOException, ArrayIndexOutOfBoundsException {
        Object value = currentRow.getObject(index);
        if (value instanceof SeShape) {
            try {
                final SeShape shape = (SeShape) value;
                final Class<? extends Geometry> actualGeomtryClass;
                if (shape.isNil()) {
                    // actualGeomtryClass = this.schemaGeometryClass;
                    value = null;
                } else {
                    actualGeomtryClass = ArcSDEAdapter.getGeometryTypeFromSeShape(shape);
                    final ArcSDEGeometryBuilder geometryBuilder;
View Full Code Here


                        throw new DataSourceException("Invalid geometry passed for " + attName
                                + "\n Geomerty: " + geom + "\n" + errorMessage);
                    }
                    ArcSDEGeometryBuilder geometryBuilder;
                    geometryBuilder = ArcSDEGeometryBuilder.builderFor(geom.getClass());
                    SeShape shape = geometryBuilder.constructShape(geom, coordRef);
                    row.setShape(index, shape);
                } else {
                    row.setShape(index, null);
                }
            }
View Full Code Here

            while (row != null) {
                featureCount++;
                for (int i = 0; i < ncols; i++) {
                    value = row.getObject(i);
                    if (i == shapeIdx) {
                        SeShape shape = (SeShape) value;
                        totalPoints += shape.getNumOfPoints();
                        double[][][] allCoords = shape.getAllCoords();
                        largerPoints = Math.max(largerPoints, shape.getNumOfPoints());
                    }
                }
                row = query.fetch();
            }
            sw.stop();
View Full Code Here

            long longFid;
            if (shapeIndex != -1) {
                // we have the shape, so SHAPE.fid couldn't be retrieved
                // at the same time, need to get the shape and ask it for the id
                try {
                    SeShape shape = row.getShape(shapeIndex);
                    if (shape == null) {
                        throw new NullPointerException("Can't get FID from " + layerName
                                + " as it has SHAPE fid reading strategy and got a null shape");
                    }
                    longFid = shape.getFeatureId().longValue();
                } catch (SeException e) {
                    throw new ArcSdeException("Getting fid from shape", e);
                }
            } else {
                int shapeIdIndex = getColumnIndex();
View Full Code Here

        } else {
            geoms = g;
        }

        final SeCoordinateReference coordref = layer.getCoordRef();
        final SeShape shapes[] = new SeShape[8];
        for (int i = 0; i < shapes.length; i++) {
            Geometry geom = geoms[i];
            SeShape shape;
            if (geom == null) {
                shape = null;
            } else {
                IsValidOp validationOp = new IsValidOp(geom);
                TopologyValidationError validationError = validationOp.getValidationError();
                if (validationError != null) {
                    throw new IllegalArgumentException("Provided geometry is invalid: "
                            + validationError.getMessage());
                }

                ArcSDEGeometryBuilder builder = ArcSDEGeometryBuilder.builderFor(geom.getClass());
                shape = builder.constructShape(geom, coordref);
            }
            shapes[i] = shape;
        }
        /*
         * Define the names of the columns that data is to be inserted into.
         */
        final String[] columns = new String[8];

        columns[0] = colDefs[1].getName(); // INT32 column
        columns[1] = colDefs[2].getName(); // INT16 column
        columns[2] = colDefs[3].getName(); // FLOAT32 column
        columns[3] = colDefs[4].getName(); // FLOAT64 column
        columns[4] = colDefs[5].getName(); // String column
        columns[5] = colDefs[6].getName(); // NString column
        columns[6] = colDefs[7].getName(); // Date column
        columns[7] = "SHAPE"; // Shape column

        Command<Void> insertDataCmd = new Command<Void>() {
            @Override
            public Void execute(ISession session, SeConnection connection) throws SeException,
                    IOException {

                SeInsert insert = new SeInsert(connection);
                insert.intoTable(layer.getName(), columns);
                insert.setWriteMode(true);

                Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                // Year, month, date, hour, minute, second.
                cal.set(2004, 06, 1, 0, 0, 0);

                try {
                    for (int i = 1; i <= shapes.length; i++) {
                        SeRow row = insert.getRowToSet();
                        // col #0 is the sde managed row id
                        row.setInteger(0, Integer.valueOf(i));
                        row.setShort(1, Short.valueOf((short) i));
                        row.setFloat(2, new Float(i / 10.0F));
                        row.setDouble(3, new Double(i / 10D));
                        row.setString(4, "FEATURE_" + i);
                        row.setNString(5, "NSTRING_" + i);
                        cal.set(Calendar.DAY_OF_MONTH, i);
                        row.setTime(6, cal);
                        SeShape seShape = shapes[i - 1];
                        row.setShape(7, seShape);

                        insert.execute();
                    }
                } finally {
View Full Code Here

    public final SeShape constructShape(final Geometry geometry, SeCoordinateReference seSrs)
            throws ArcSdeException {
        if (geometry == null) {
            return null;
        }
        SeShape shape = null;

        try {
            shape = new SeShape(seSrs);
        } catch (SeException ex) {
            ArcSdeException e = new ArcSdeException("Can't create SeShape with SeCrs " + seSrs, ex);
            LOGGER.log(Level.WARNING, e.getMessage(), e);
            throw e;
        }

        if (geometry.isEmpty()) {
            return shape;
        }

        // REVISIT: this may be worth considering. If not, at least shape.generateFromWKB
        // final String wkt = geometry.toText();
        // try {
        // shape.generateFromText(wkt);
        // } catch (SeException e) {
        // ArcSdeException sdeEx = new ArcSdeException("Can't generate SeShape from " + geometry
        // + "\n", e);
        // LOGGER.log(Level.WARNING, sdeEx.getMessage());
        // throw sdeEx;
        // }

        int numParts;
        GeometryCollection gcol = null;

        if (geometry instanceof GeometryCollection) {
            gcol = (GeometryCollection) geometry;
        } else {
            Geometry[] geoms = { geometry };
            gcol = new GeometryFactory().createGeometryCollection(geoms);
        }

        List<SDEPoint> allPoints = new ArrayList<SDEPoint>();
        numParts = gcol.getNumGeometries();

        int[] partOffsets = new int[numParts];
        Geometry geom;
        Coordinate[] coords;
        Coordinate c;

        for (int currGeom = 0; currGeom < numParts; currGeom++) {
            partOffsets[currGeom] = allPoints.size();
            geom = gcol.getGeometryN(currGeom);

            coords = geom.getCoordinates();

            for (int i = 0; i < coords.length; i++) {
                c = coords[i];
                allPoints.add(new SDEPoint(c.x, c.y));
            }
        }

        SDEPoint[] points = new SDEPoint[allPoints.size()];
        allPoints.toArray(points);

        try {
            if (geometry instanceof Point || gcol instanceof MultiPoint) {
                shape.generatePoint(points.length, points);
            } else if (geometry instanceof LineString || geometry instanceof MultiLineString) {
                shape.generateLine(points.length, numParts, partOffsets, points);
            } else {
                shape.generatePolygon(points.length, numParts, partOffsets, points);
            }
        } catch (SeException e) {
            ArcSdeException sdeEx = new ArcSdeException("Can't generate SeShape from " + geometry
                    + "\n", e);
            LOGGER.log(Level.WARNING, sdeEx.getMessage());
View Full Code Here

        // add a bounding box filter and verify both spatial and non spatial
        // constraints affects the COUNT statistics
        SeExtent extent = new SeExtent(-180, -90, -170, -80);

        SeLayer layer = session.getLayer(typeName);
        SeShape filterShape = new SeShape(layer.getCoordRef());
        filterShape.generateRectangle(extent);

        SeShapeFilter bboxFilter = new SeShapeFilter(typeName, layer.getSpatialColumn(),
                filterShape, SeFilter.METHOD_ENVP, true);
        final SeFilter[] spatFilters = { bboxFilter };
View Full Code Here

            // add a bounding box filter and verify both spatial and non spatial
            // constraints affects the COUNT statistics
            SeExtent extent = new SeExtent(-180, -90, -170, -80);

            SeLayer layer = session.getLayer(typeName);
            SeShape filterShape = new SeShape(layer.getCoordRef());
            filterShape.generateRectangle(extent);

            SeShapeFilter bboxFilter = new SeShapeFilter(typeName, layer.getSpatialColumn(),
                    filterShape, SeFilter.METHOD_ENVP, true);
            SeFilter[] spatFilters = { bboxFilter };
View Full Code Here

            int actualCount;

            SeExtent extent = new SeExtent(-180, -90, -170, -80);

            SeLayer layer = session.getLayer(typeName);
            SeShape filterShape = new SeShape(layer.getCoordRef());
            filterShape.generateRectangle(extent);

            SeShapeFilter bboxFilter = new SeShapeFilter(typeName, layer.getSpatialColumn(),
                    filterShape, SeFilter.METHOD_ENVP, true);
            SeFilter[] spatFilters = { bboxFilter };
View Full Code Here

        String[] cols = { "SHAPE" };
        final SeFilter[] spatFilters;
        try {
            SeExtent extent = new SeExtent(179, -1, 180, 0);
            SeLayer layer = session.getLayer(typeName);
            SeShape filterShape = new SeShape(layer.getCoordRef());
            filterShape.generateRectangle(extent);

            SeShapeFilter bboxFilter = new SeShapeFilter(typeName, layer.getSpatialColumn(),
                    filterShape, SeFilter.METHOD_ENVP, true);
            spatFilters = new SeFilter[] { bboxFilter };
        } catch (SeException eek) {
View Full Code Here

TOP

Related Classes of com.esri.sde.sdk.client.SeShape

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.