Esempio n. 1
0
 private static bool LineStringToLineStripAdjacency(GeoAPI.Geometries.ILineString _lineString, Ellipsoid _shape, List <Vector2> positions, List <ushort> indices)
 {
     if (_lineString == null)
     {
         throw new Exception("_lineString is Null");
     }
     if (_lineString.IsClosed)
     {
         //记录起点
         ushort indicesMax = (ushort)positions.Count();
         //添加第一个环的最后一个点
         indices.Add((ushort)(indicesMax + _lineString.Coordinates.Length - 2));
         //对于polygon来说第一个点和最后一个点是相同的,因此只添加一次
         for (int i = 0; i < _lineString.Coordinates.Length - 1; i++)
         {
             var coord    = _lineString.Coordinates[i];
             var geoDetic = new Vector2(MathExtension.ToRadius(coord.X), MathExtension.ToRadius(coord.Y));
             positions.Add(geoDetic);
             indices.Add((ushort)(indicesMax + i));
         }
         //添加起点
         indices.Add((ushort)(indicesMax));
         //添加第二个点
         indices.Add((ushort)(indicesMax + 1));
     }
     else
     {
         //非闭合的情况下,首尾特殊处理即可
         throw new Exception("Not Support!");
     }
     return(true);
 }
Esempio n. 2
0
        internal static DotSpatial.Topology.LineString ToDotSpatialLineString(GeoAPI.Geometries.ILineString l)
        {
            DotSpatial.Topology.Coordinate[] c = new DotSpatial.Topology.Coordinate[l.Coordinates.Count()];

            for (int i = 0; i < l.Coordinates.Count(); i++)
            {
                c[i] = new DotSpatial.Topology.Coordinate(l.Coordinates[i].X, l.Coordinates[i].Y);
            }
            return(new DotSpatial.Topology.LineString(c));
        }
Esempio n. 3
0
        internal static Geometries.LineString ToSharpMapLineString(NTSLineString geom)
        {
            Collection <Geometries.Point> vertices = new Collection <Geometries.Point>();

            foreach (Coordinate coordinate in geom.Coordinates)
            {
                vertices.Add(ToSharpMapPoint(coordinate));
            }
            return(new Geometries.LineString(vertices));
        }
        private static SMMultiLineString SqlGeometryToSharpMapMultiLineString(SqlGeometry geometry, Factory factory)
        {
            var fact        = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid);
            var lineStrings = new SMLineString[(int)geometry.STNumGeometries()];

            for (var i = 1; i <= geometry.STNumGeometries(); i++)
            {
                lineStrings[i - 1] = (SMLineString)SqlGeometryToSharpMapLineString(geometry.STGeometryN(i), fact);
            }
            return(fact.CreateMultiLineString(lineStrings));
        }
Esempio n. 5
0
        internal static NTSMultiLineString ToNTSMultiLineString(Geometries.MultiLineString geom,
                                                                IGeometryFactory factory)
        {
            NTSLineString[] lstrings = new NTSLineString[geom.LineStrings.Count];
            int             index    = 0;

            foreach (Geometries.LineString lstring in geom.LineStrings)
            {
                lstrings[index++] = ToNTSLineString(lstring, factory);
            }
            return(factory.CreateMultiLineString(lstrings) as NTSMultiLineString);
        }
        private static void SharpMapLineStringToSqlGeometry(SqlGeometryBuilder geomBuilder, SMLineString lineString)
        {
            geomBuilder.BeginGeometry(OpenGisGeometryType.LineString);
            var coords = lineString.Coordinates;

            geomBuilder.BeginFigure(coords[0].X, coords[0].Y);
            for (int i = 1; i < lineString.NumPoints; i++)
            {
                var point = coords[i];
                geomBuilder.AddLine(point.X, point.Y);
            }
            geomBuilder.EndFigure();
            geomBuilder.EndGeometry();
        }
 private static SMMultiLineString SqlGeometryToSharpMapMultiLineString(SqlGeometry geometry, Factory factory)
 {
     var fact = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid);
     var lineStrings = new SMLineString[(int)geometry.STNumGeometries()];
     for (var i = 1; i <= geometry.STNumGeometries(); i++)
         lineStrings[i-1] = (SMLineString)SqlGeometryToSharpMapLineString(geometry.STGeometryN(i), fact);
     return fact.CreateMultiLineString(lineStrings);
 }
 private static void SharpMapLineStringToSqlGeometry(SqlGeometryBuilder geomBuilder, SMLineString lineString)
 {
     geomBuilder.BeginGeometry(OpenGisGeometryType.LineString);
     var coords = lineString.Coordinates;
     geomBuilder.BeginFigure(coords[0].X, coords[0].Y);
     for (int i = 1; i < lineString.NumPoints; i++)
     {
         var point = coords[i];
         geomBuilder.AddLine(point.X, point.Y);
     }
     geomBuilder.EndFigure();
     geomBuilder.EndGeometry();
 }
Esempio n. 9
0
 internal static Geometries.LineString ToSharpMapLineString(NTSLineString geom)
 {
     Collection<Geometries.Point> vertices = new Collection<Geometries.Point>();
     foreach (Coordinate coordinate in geom.Coordinates)
         vertices.Add(ToSharpMapPoint(coordinate));
     return new Geometries.LineString(vertices);
 }
Esempio n. 10
0
 internal static NTSMultiLineString ToNTSMultiLineString(Geometries.MultiLineString geom,
     IGeometryFactory factory)
 {
     NTSLineString[] lstrings = new NTSLineString[geom.LineStrings.Count];
     int index = 0;
     foreach (Geometries.LineString lstring in geom.LineStrings)
         lstrings[index++] = ToNTSLineString(lstring, factory);
     return factory.CreateMultiLineString(lstrings) as NTSMultiLineString;
 }