Exemplo n.º 1
0
        /**
         * Return SDO_ELEM_INFO array for geometry
         *
         * <pre><code><b>
         * # Name                Meaning</b>
         * 0 SDO_STARTING_OFFSET Offsets start at one
         * 1 SDO_ETYPE           Describes how ordinates are ordered
         * 2 SDO_INTERPRETATION  SDO_ETYPE: 4, 1005, or 2005
         *                       Number of triplets involved in compound geometry
         *
         *                       SDO_ETYPE: 1, 2, 1003, or 2003
         *                       Describes ordering of ordinates in geometry
         * </code></pre>
         *
         * <p>
         * For compound elements (SDO_ETYPE values 4 and 5) the last element of one
         * is the first element of the next.
         * </p>
         *
         * @param geom Geometry being represented
         *
         * @return Descriptionof Ordinates representation
         */
        private int[] ElemInfo(IGeometry geom, SdoGTemplate gtype)
        {
            var list = new LinkedList <int>();

            ElemInfo(list, geom, 1, gtype);

            int[] array  = new int[list.Count];
            int   offset = 0;

            foreach (var i in list)
            {
                array[offset++] = i;
            }

            return(array);
        }
Exemplo n.º 2
0
        /**
         * Add to SDO_ELEM_INFO list for geometry and GTYPE.
         *
         * @param elemInfoList List used to gather SDO_ELEM_INFO
         * @param geom Geometry to encode
         * @param sOffSet Starting offset in SDO_ORDINATES
         *
         * @throws IllegalArgumentException If geom cannot be encoded by ElemInfo
         */
        private void ElemInfo(LinkedList <int> elemInfoList, IGeometry geom, int sOffSet, SdoGTemplate gtype)
        {
            switch (gtype - ((int)gtype / 100) * 100) // removes right two digits
            {
            case SdoGTemplate.Coordinate:
                addInt(elemInfoList, sOffSet);
                addInt(elemInfoList, (int)SdoEType.Coordinate);
                addInt(elemInfoList, 1); // INTERPRETATION single point

                return;

            case SdoGTemplate.MultiPoint:
                var points = (IMultiPoint)geom;

                addInt(elemInfoList, sOffSet);
                addInt(elemInfoList, (int)SdoEType.Coordinate);
                addInt(elemInfoList, ElemInfoInterpretation(points, SdoEType.Coordinate));

                return;

            case SdoGTemplate.Line:
                addInt(elemInfoList, sOffSet);
                addInt(elemInfoList, (int)SdoEType.Line);
                addInt(elemInfoList, 1); // INTERPRETATION straight edges

                return;

            case SdoGTemplate.MultiLine:
                var         lines = (IMultiLineString)geom;
                ILineString line;
                int         offset = sOffSet;
                int         dim    = (int)gtype / 1000;
                int         len    = dim + ((int)gtype - dim * 1000) / 100;

                for (int i = 0; i < lines.NumGeometries; i++)
                {
                    line = (ILineString)lines.GetGeometryN(i);
                    addInt(elemInfoList, offset);
                    addInt(elemInfoList, (int)SdoEType.Line);
                    addInt(elemInfoList, 1); // INTERPRETATION straight edges
                    offset += (line.NumPoints * len);
                }

                return;

            case SdoGTemplate.Polygon:
                var polygon = (IPolygon)geom;
                int holes   = polygon.NumInteriorRings;

                if (holes == 0)
                {
                    addInt(elemInfoList, sOffSet);
                    addInt(elemInfoList, (int)ElemInfoEType(polygon));
                    addInt(elemInfoList, ElemInfoInterpretation(polygon, SdoEType.PolygonExterior));
                    return;
                }

                dim    = (int)gtype / 1000;
                len    = dim + ((int)gtype - dim * 1000) / 100;
                offset = sOffSet;
                ILineString ring;

                ring = polygon.ExteriorRing;
                addInt(elemInfoList, offset);
                addInt(elemInfoList, (int)ElemInfoEType(polygon));
                addInt(elemInfoList, ElemInfoInterpretation(polygon, SdoEType.PolygonExterior));
                offset += (ring.NumPoints * len);

                for (int i = 1; i <= holes; i++)
                {
                    ring = polygon.GetInteriorRingN(i - 1);
                    addInt(elemInfoList, offset);
                    addInt(elemInfoList, (int)SdoEType.PolygonInterior);
                    addInt(elemInfoList, ElemInfoInterpretation(ring, SdoEType.PolygonInterior));
                    offset += (ring.NumPoints * len);
                }

                return;

            case SdoGTemplate.MultiPolygon:
                var      polys = (IMultiPolygon)geom;
                IPolygon poly;
                offset = sOffSet;

                dim = (int)gtype / 1000;
                len = dim + ((int)gtype - dim * 1000) / 100;

                for (int i = 0; i < polys.NumGeometries; i++)
                {
                    poly = (IPolygon)polys.GetGeometryN(i);
                    ElemInfo(elemInfoList, poly, offset, GType(poly));
                    if (IsRectangle(poly))
                    {
                        offset += (2 * len);
                    }
                    else
                    {
                        offset += (poly.NumPoints * len);
                    }
                }

                return;

            case SdoGTemplate.Collection:
                var geoms = (IGeometryCollection)geom;
                offset = sOffSet;
                dim    = (int)gtype / 1000;
                len    = dim + ((int)gtype - dim * 1000) / 100;

                for (int i = 0; i < geoms.NumGeometries; i++)
                {
                    geom = geoms.GetGeometryN(i);
                    // MD  20/3/07 modified to provide gType of component geometry
                    ElemInfo(elemInfoList, geom, offset, GType(geom));
                    if (geom is IPolygon && IsRectangle((IPolygon)geom))
                    {
                        offset += (2 * len);
                    }
                    else
                    {
                        offset += (geom.NumPoints * len);
                    }
                }

                return;
            }

            throw new ArgumentException("Cannot encode JTS "
                                        + geom.GeometryType + " as SDO_ELEM_INFO "
                                        + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
                                        + " MultiLineString and MultiPolygon)");
        }
    /**
     * Add to SDO_ELEM_INFO list for geometry and GTYPE.
     *
     * @param elemInfoList List used to gather SDO_ELEM_INFO
     * @param geom Geometry to encode
     * @param sOffSet Starting offset in SDO_ORDINATES
     *
     * @throws IllegalArgumentException If geom cannot be encoded by ElemInfo
     */
    private void ElemInfo(LinkedList<int> elemInfoList, IGeometry geom, int sOffSet, SdoGTemplate gtype) {

        switch (gtype - ((int)gtype/100) * 100) { // removes right two digits
        case SdoGTemplate.Coordinate:
            addInt(elemInfoList, sOffSet);
            addInt(elemInfoList, (int)SdoEType.Coordinate);
            addInt(elemInfoList, 1); // INTERPRETATION single point

            return;

        case SdoGTemplate.MultiPoint:
            var points = (IMultiPoint) geom;

            addInt(elemInfoList, sOffSet);
            addInt(elemInfoList, (int)SdoEType.Coordinate);
            addInt(elemInfoList, ElemInfoInterpretation(points, SdoEType.Coordinate));

            return;

        case SdoGTemplate.Line:
            addInt(elemInfoList, sOffSet);
            addInt(elemInfoList, (int)SdoEType.Line);
            addInt(elemInfoList, 1); // INTERPRETATION straight edges    

            return;

        case SdoGTemplate.MultiLine:
        	var lines = (IMultiLineString) geom;
            ILineString line;
            int offset = sOffSet;
            int dim = (int)gtype/1000;
            int len = dim + ((int)gtype-dim*1000)/100;

            for (int i = 0; i < lines.NumGeometries; i++) {
                line = (ILineString) lines.GetGeometryN(i);
                addInt(elemInfoList, offset);
                addInt(elemInfoList, (int)SdoEType.Line);
                addInt(elemInfoList, 1); // INTERPRETATION straight edges  
                offset += (line.NumPoints * len);
            }

            return;

        case SdoGTemplate.Polygon:
        	var polygon = (IPolygon)geom;
            int holes = polygon.NumInteriorRings;

            if (holes == 0) {
                addInt(elemInfoList, sOffSet);
                addInt(elemInfoList, (int)ElemInfoEType(polygon));
                addInt(elemInfoList, ElemInfoInterpretation(polygon, SdoEType.PolygonExterior));
                return;
            }

            dim = (int)gtype/1000;
            len = dim + ((int)gtype-dim*1000)/100;
            offset = sOffSet;
            ILineString ring;

            ring = polygon.ExteriorRing;
            addInt(elemInfoList, offset);
            addInt(elemInfoList, (int)ElemInfoEType(polygon));
            addInt(elemInfoList, ElemInfoInterpretation(polygon, SdoEType.PolygonExterior));
            offset += (ring.NumPoints * len);

            for (int i = 1; i <= holes; i++) {
                ring = polygon.GetInteriorRingN(i - 1);
                addInt(elemInfoList, offset);
                addInt(elemInfoList, (int)SdoEType.PolygonInterior);
                addInt(elemInfoList, ElemInfoInterpretation(ring, SdoEType.PolygonInterior));
                offset += (ring.NumPoints * len);
            }

            return;

        case SdoGTemplate.MultiPolygon:
        	var polys = (IMultiPolygon) geom;
            IPolygon poly;
            offset = sOffSet;

            dim = (int)gtype/1000;
            len = dim + ((int)gtype-dim*1000)/100;

            for (int i = 0; i < polys.NumGeometries; i++) {
                poly = (IPolygon) polys.GetGeometryN(i);
                ElemInfo(elemInfoList, poly, offset, GType(poly));
                if( IsRectangle( poly )){
                    offset += (2 * len);                
                }
                else {
                    offset += (poly.NumPoints * len);                
                }            
            }

            return;

        case SdoGTemplate.Collection:
        	var geoms = (IGeometryCollection) geom;
            offset = sOffSet;
            dim = (int)gtype/1000;
            len = dim + ((int)gtype-dim*1000)/100;

            for (int i = 0; i < geoms.NumGeometries; i++) {
                geom = geoms.GetGeometryN(i);
                // MD  20/3/07 modified to provide gType of component geometry
                ElemInfo(elemInfoList, geom, offset, GType(geom));
                if( geom is IPolygon && IsRectangle( (IPolygon) geom )){
                    offset += (2 * len);                
                }
                else {
                    offset += (geom.NumPoints * len);                
                }                        
            }

            return;
        }

        throw new ArgumentException("Cannot encode JTS "
            + geom.GeometryType + " as SDO_ELEM_INFO "
            + "(Limitied to Point, Line, Polygon, GeometryCollection, MultiPoint,"
            + " MultiLineString and MultiPolygon)");
    }
    /**
     * Return SDO_ELEM_INFO array for geometry
     * 
     * <pre><code><b>
     * # Name                Meaning</b>
     * 0 SDO_STARTING_OFFSET Offsets start at one
     * 1 SDO_ETYPE           Describes how ordinates are ordered
     * 2 SDO_INTERPRETATION  SDO_ETYPE: 4, 1005, or 2005
     *                       Number of triplets involved in compound geometry
     *                       
     *                       SDO_ETYPE: 1, 2, 1003, or 2003
     *                       Describes ordering of ordinates in geometry  
     * </code></pre>
     * 
     * <p>
     * For compound elements (SDO_ETYPE values 4 and 5) the last element of one
     * is the first element of the next.
     * </p>
     *
     * @param geom Geometry being represented
     *
     * @return Descriptionof Ordinates representation
     */
	private int[] ElemInfo(IGeometry geom, SdoGTemplate gtype) {
		var list = new LinkedList<int>();

        ElemInfo(list, geom, 1, gtype);
        
        int[] array = new int[list.Count];
        int offset = 0;

	    foreach (var i in list)
	    {
            array[offset++] = i;
        }

        return array;
    }