public static RoadSegmentBoundingBox From(PolyLineM shape) => new RoadSegmentBoundingBox { MinimumX = GeometryTranslator.ToGeometryMultiLineString(shape).EnvelopeInternal.MinX, MinimumY = GeometryTranslator.ToGeometryMultiLineString(shape).EnvelopeInternal.MinY, MaximumX = GeometryTranslator.ToGeometryMultiLineString(shape).EnvelopeInternal.MaxX, MaximumY = GeometryTranslator.ToGeometryMultiLineString(shape).EnvelopeInternal.MaxY, MinimumM = GeometryTranslator.ToGeometryMultiLineString(shape).GetOrdinates(Ordinate.M).DefaultIfEmpty(double.NegativeInfinity).Min(), MaximumM = GeometryTranslator.ToGeometryMultiLineString(shape).GetOrdinates(Ordinate.M).DefaultIfEmpty(double.PositiveInfinity).Max() };
private void _read() { _shapeType = ((ShapefileMain.ShapeType)m_io.ReadS4le()); if (ShapeType != ShapefileMain.ShapeType.NullShape) { switch (ShapeType) { case ShapefileMain.ShapeType.PointM: { _shapeParameters = new PointM(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PolygonZ: { _shapeParameters = new PolygonZ(m_io, this, m_root); break; } case ShapefileMain.ShapeType.MultiPointM: { _shapeParameters = new MultiPointM(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PolyLineZ: { _shapeParameters = new PolyLineZ(m_io, this, m_root); break; } case ShapefileMain.ShapeType.MultiPointZ: { _shapeParameters = new MultiPointZ(m_io, this, m_root); break; } case ShapefileMain.ShapeType.MultiPoint: { _shapeParameters = new MultiPoint(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PolygonM: { _shapeParameters = new PolygonM(m_io, this, m_root); break; } case ShapefileMain.ShapeType.Polygon: { _shapeParameters = new Polygon(m_io, this, m_root); break; } case ShapefileMain.ShapeType.Point: { _shapeParameters = new Point(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PolyLineM: { _shapeParameters = new PolyLineM(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PolyLine: { _shapeParameters = new PolyLine(m_io, this, m_root); break; } case ShapefileMain.ShapeType.PointZ: { _shapeParameters = new PointZ(m_io, this, m_root); break; } case ShapefileMain.ShapeType.MultiPatch: { _shapeParameters = new MultiPatch(m_io, this, m_root); break; } } } }
public static NetTopologySuite.Geometries.MultiLineString ToGeometryMultiLineString(PolyLineM polyLineM) { if (polyLineM == null) { throw new ArgumentNullException(nameof(polyLineM)); } var coordinates = Array.ConvertAll(polyLineM.Points, point => new NetTopologySuite.Geometries.Coordinate(point.X, point.Y)); if (polyLineM.Measures != null) { for (var measureIndex = 0; measureIndex < polyLineM.Measures.Length; measureIndex++) { coordinates[measureIndex] = new NetTopologySuite.Geometries.CoordinateM(coordinates[measureIndex].X, coordinates[measureIndex].Y, polyLineM.Measures[measureIndex]); } } var lines = new NetTopologySuite.Geometries.LineString[polyLineM.NumberOfParts]; var toCoordinateIndex = coordinates.Length; for (var partIndex = polyLineM.NumberOfParts - 1; partIndex >= 0; partIndex--) { var fromCoordinateIndex = polyLineM.Parts[partIndex]; lines[partIndex] = new NetTopologySuite.Geometries.LineString( GeometryConfiguration.GeometryFactory.CoordinateSequenceFactory.Create( new ArraySegment <NetTopologySuite.Geometries.Coordinate>( coordinates, fromCoordinateIndex, toCoordinateIndex - fromCoordinateIndex).ToArray() ), GeometryConfiguration.GeometryFactory); toCoordinateIndex = fromCoordinateIndex; } return(new NetTopologySuite.Geometries.MultiLineString(lines)); }