Beispiel #1
0
 public static extern System.Int32 SE_stream_set_shape(SE_STREAM stream, System.Int16 column, SE_SHAPE shape_val);
Beispiel #2
0
 public static extern System.Int32 SE_shape_get_num_points(SE_SHAPE shape, System.Int32 part_num, System.Int32 subpart_num, ref System.Int32 num_pts);
Beispiel #3
0
 public static extern System.Int32 SE_shape_generate_polygon(System.Int32 num_pts, System.Int32 num_parts, IntPtr part_offsets, IntPtr point_array, IntPtr z, IntPtr measure, SE_SHAPE tgt_shape);
Beispiel #4
0
 public static extern System.Int32 SE_shape_get_type(SE_SHAPE shape, ref System.Int32 shape_type);
Beispiel #5
0
 public static extern System.Int32 SE_shape_get_num_parts(SE_SHAPE shape, ref System.Int32 num_partsref, ref System.Int32 num_subparts);
Beispiel #6
0
 public static extern System.Int32 SE_shape_get_all_points(SE_SHAPE shape, SE_ROTATION_TYPE rotation, IntPtr part_offsets, IntPtr subpart_offsets, IntPtr point_array, IntPtr z, IntPtr measure);
Beispiel #7
0
 public static extern System.Int32 SE_shape_generate_rectangle(ref SE_ENVELOPE rect, SE_SHAPE tgt_shape);
Beispiel #8
0
 public static extern void SE_shape_free(SE_SHAPE shape);
Beispiel #9
0
 public static extern System.Int32 SE_shape_create(SE_COORDREF coordref, ref SE_SHAPE shape);
Beispiel #10
0
        public static System.Int32 SE_GenerateGeometry(SE_SHAPE shape, IGeometry geometry, SE_ENVELOPE maxExtent)
        {
            if (geometry == null)
            {
                return(-1);
            }

            unsafe
            {
                SE_POINT *    points = null;
                System.Int32 *parts  = null;
                switch (geometry.GeometryType)
                {
                case geometryType.Envelope:
                    SE_ENVELOPE seEnvelope = new SE_ENVELOPE();
                    IEnvelope   env        = geometry.Envelope;
                    seEnvelope.minx = Math.Max(env.minx, maxExtent.minx);
                    seEnvelope.miny = Math.Max(env.miny, maxExtent.miny);
                    seEnvelope.maxx = Math.Min(env.maxx, maxExtent.maxx);
                    seEnvelope.maxy = Math.Min(env.maxy, maxExtent.maxy);

                    if (seEnvelope.minx == seEnvelope.maxx && seEnvelope.miny == seEnvelope.maxy)
                    {
                        /* fudge a rectangle so we have a valid one for generate_rectangle */

                        /* FIXME: use the real shape for the query and set the filter_type
                         * to be an appropriate type */
                        seEnvelope.minx = seEnvelope.minx - 0.001;
                        seEnvelope.maxx = seEnvelope.maxx + 0.001;
                        seEnvelope.miny = seEnvelope.miny - 0.001;
                        seEnvelope.maxy = seEnvelope.maxy + 0.001;
                    }
                    return(Wrapper10.SE_shape_generate_rectangle(ref seEnvelope, shape));

                case geometryType.Point:
                    points      = (SE_POINT *)Marshal.AllocHGlobal(sizeof(SE_POINT) * 1);
                    points[0].x = ((IPoint)geometry).X;
                    points[0].y = ((IPoint)geometry).Y;
                    return(Wrapper10.SE_shape_generate_point(1, (IntPtr)points, (IntPtr)null, (IntPtr)null, shape));

                case geometryType.Polyline:
                    IPointCollection col1     = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPoints(geometry, false);
                    IPolyline        polyline = (IPolyline)geometry;
                    points = (SE_POINT *)Marshal.AllocHGlobal(sizeof(SE_POINT) * (col1.PointCount));
                    parts  = (Int32 *)Marshal.AllocHGlobal(sizeof(Int32) * polyline.PathCount);

                    int pos1 = 0;
                    for (int i = 0; i < polyline.PathCount; i++)
                    {
                        parts[i] = pos1;
                        IPath path = polyline[i];
                        if (path.PointCount == 0)
                        {
                            continue;
                        }
                        for (int p = 0; p < path.PointCount; p++)
                        {
                            points[pos1].x = path[p].X;
                            points[pos1].y = path[p].Y;
                            pos1++;
                        }
                    }

                    return(Wrapper10.SE_shape_generate_line(pos1, polyline.PathCount, (IntPtr)parts, (IntPtr)points, (IntPtr)null, (IntPtr)null, shape));

                case geometryType.Polygon:
                    IPointCollection col2    = gView.Framework.SpatialAlgorithms.Algorithm.GeometryPoints(geometry, false);
                    IPolygon         polygon = (IPolygon)geometry;
                    points = (SE_POINT *)Marshal.AllocHGlobal(sizeof(SE_POINT) * (col2.PointCount + polygon.RingCount));
                    parts  = (Int32 *)Marshal.AllocHGlobal(sizeof(Int32) * polygon.RingCount);

                    int pos2 = 0;
                    for (int i = 0; i < polygon.RingCount; i++)
                    {
                        parts[i] = pos2;
                        IRing ring = polygon[i];
                        if (ring.PointCount == 0)
                        {
                            continue;
                        }
                        for (int p = 0; p < ring.PointCount; p++)
                        {
                            points[pos2].x = ring[p].X;
                            points[pos2].y = ring[p].Y;
                            pos2++;
                        }
                        points[pos2].x = ring[0].X;
                        points[pos2].y = ring[0].Y;
                        pos2++;
                    }

                    return(Wrapper10.SE_shape_generate_polygon(pos2, polygon.RingCount, (IntPtr)parts, (IntPtr)points, (IntPtr)null, (IntPtr)null, shape));

                case geometryType.Aggregate:
                    if (((AggregateGeometry)geometry).GeometryCount == 1)
                    {
                        return(SE_GenerateGeometry(shape, ((AggregateGeometry)geometry)[0], maxExtent));
                    }
                    //else
                    //{
                    //    Polygon polygon = new Polygon();
                    //    for (int i = 0; i < ((AggregateGeometry)geometry).GeometryCount; i++)
                    //    {
                    //        IGeometry g = ((AggregateGeometry)geometry)[i];
                    //        if (g is IPolygon)
                    //        {
                    //            for (int p = 0; p < ((IPolygon)g).RingCount; p++)
                    //                polygon.AddRing(((Polygon)g)[p]);
                    //        }
                    //    }
                    //    if (polygon.RingCount > 0) return SE_GenerateGeometry(shape, polygon, maxExtent);
                    //}
                    return(-1);
                }
            }

            return(-1);
        }