コード例 #1
0
 public static extern System.Int64 SE_stream_set_shape(SE_STREAM_64 stream, System.Int16 column, SE_SHAPE_64 shape_val);
コード例 #2
0
 public static extern System.Int64 SE_shape_get_num_points(SE_SHAPE_64 shape, System.Int64 part_num, System.Int64 subpart_num, ref System.Int64 num_pts);
コード例 #3
0
 public static extern System.Int64 SE_shape_generate_polygon(System.Int64 num_pts, System.Int64 num_parts, IntPtr part_offsets, IntPtr point_array, IntPtr z, IntPtr measure, SE_SHAPE_64 tgt_shape);
コード例 #4
0
 public static extern System.Int64 SE_shape_get_type(SE_SHAPE_64 shape, ref System.Int64 shape_type);
コード例 #5
0
 public static extern System.Int64 SE_shape_get_num_parts(SE_SHAPE_64 shape, ref System.Int64 num_partsref, ref System.Int64 num_subparts);
コード例 #6
0
 public static extern System.Int64 SE_shape_get_all_points(SE_SHAPE_64 shape, SE_ROTATION_TYPE rotation, IntPtr part_offsets, IntPtr subpart_offsets, IntPtr point_array, IntPtr z, IntPtr measure);
コード例 #7
0
 public static extern System.Int64 SE_shape_generate_rectangle(ref SE_ENVELOPE rect, SE_SHAPE_64 tgt_shape);
コード例 #8
0
 public static extern void SE_shape_free(SE_SHAPE_64 shape);
コード例 #9
0
 public static extern System.Int64 SE_shape_create(SE_COORDREF_64 coordref, ref SE_SHAPE_64 shape);
コード例 #10
0
ファイル: Functions.cs プロジェクト: jugstalt/gViewGisOS
        public static System.Int64 SE_GenerateGeometry(SE_SHAPE_64 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(Wrapper92_64.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(Wrapper92_64.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(Wrapper92_64.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(Wrapper92_64.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);
        }