public void BeginGeography(OpenGisGeographyType type) { if (m_TargetSink != null) { m_TargetSink.BeginGeography(type); } }
public void BeginGeography(OpenGisGeographyType type) { if (_geomCollection == null) { _geomCollection = new SinkGeometryCollection <OpenGisGeographyType>(type); if (type == OpenGisGeographyType.GeometryCollection) { _isGeometryCollection = true; } } _currentGeometry = new SinkGeometry <OpenGisGeographyType>(type); if (_isGeometryCollection && _nestLevel > 0) { if (_nestLevel == 1) { _geomCollection.SubItems.Add(new SinkGeometryCollection <OpenGisGeographyType>(type)); } _geomCollection.SubItems.Last().Add(_currentGeometry); } else { _geomCollection.Add(_currentGeometry); } _nestLevel++; }
private SpatialType ToSystemSpatialType(OpenGisGeographyType type) { switch (type) { case OpenGisGeographyType.Point: return(SpatialType.Point); case OpenGisGeographyType.LineString: return(SpatialType.LineString); case OpenGisGeographyType.Polygon: return(SpatialType.Polygon); case OpenGisGeographyType.MultiPoint: return(SpatialType.MultiPoint); case OpenGisGeographyType.MultiLineString: return(SpatialType.MultiLineString); case OpenGisGeographyType.MultiPolygon: return(SpatialType.MultiPolygon); case OpenGisGeographyType.GeometryCollection: return(SpatialType.Collection); case OpenGisGeographyType.FullGlobe: return(SpatialType.FullGlobe); default: return(SpatialType.Unknown); } }
// Start the geography. Throw if it isn't a LineString. public void BeginGeography(OpenGisGeographyType type) { if (type != OpenGisGeographyType.LineString) { throw new ArgumentException("This operation may only be executed on LineString instances."); } }
public void EndGeography() { IGeometry geometry = null; OpenGisGeographyType type = _types.Pop(); switch (type) { case OpenGisGeographyType.Point: geometry = BuildPoint(); break; case OpenGisGeographyType.LineString: geometry = BuildLineString(); break; case OpenGisGeographyType.Polygon: geometry = BuildPolygon(); break; case OpenGisGeographyType.MultiPoint: geometry = BuildMultiPoint(); break; case OpenGisGeographyType.MultiLineString: geometry = BuildMultiLineString(); break; case OpenGisGeographyType.MultiPolygon: geometry = BuildMultiPolygon(); break; case OpenGisGeographyType.GeometryCollection: geometry = BuildGeometryCollection(); break; } if (_types.Count == 0) { _geometry = geometry; if (_geometry != null) { _geometry.SRID = _srid; } } else { switch (type) { case OpenGisGeographyType.GeometryCollection: case OpenGisGeographyType.MultiPoint: case OpenGisGeographyType.MultiLineString: case OpenGisGeographyType.MultiPolygon: _ccGeometriesStack.Pop(); _ccGeometries = _ccGeometriesStack.Peek(); break; } _ccGeometries.Add(geometry); } }
public void BeginGeography(OpenGisGeographyType type) { if (_geomCollection == null) { _geomCollection = new SinkGeometryCollection<OpenGisGeographyType>(type); if (type == OpenGisGeographyType.GeometryCollection) { _isGeometryCollection = true; } } _currentGeometry = new SinkGeometry<OpenGisGeographyType>(type); if (_isGeometryCollection && _nestLevel > 0) { if (_nestLevel == 1) { _geomCollection.SubItems.Add(new SinkGeometryCollection<OpenGisGeographyType>(type)); } _geomCollection.SubItems.Last().Add(_currentGeometry); } else { _geomCollection.Add(_currentGeometry); } _nestLevel++; }
public static IGeoJsonGeometry AsGeoJson(this SqlGeography geography, bool isLongitudeFirst = true) { OpenGisGeographyType geometryType = geography.GetOpenGisType(); switch (geometryType) { case OpenGisGeographyType.Point: return(geography.SqlPointToGeoJsonPoint(isLongitudeFirst)); case OpenGisGeographyType.MultiPoint: return(SqlMultiPointToGeoJsonMultiPoint(geography, isLongitudeFirst)); case OpenGisGeographyType.LineString: return(SqlLineStringToGeoJsonPolyline(geography, isLongitudeFirst)); case OpenGisGeographyType.MultiLineString: return(SqlMultiLineStringToGeoJsonPolyline(geography, isLongitudeFirst)); case OpenGisGeographyType.Polygon: return(SqlPolygonToGeoJsonPolygon(geography, isLongitudeFirst)); case OpenGisGeographyType.MultiPolygon: return(SqlMultiPolygonToGeoJsonMultiPolygon(geography, isLongitudeFirst)); case OpenGisGeographyType.GeometryCollection: case OpenGisGeographyType.CircularString: case OpenGisGeographyType.CompoundCurve: case OpenGisGeographyType.CurvePolygon: case OpenGisGeographyType.FullGlobe: default: //return null; throw new NotImplementedException(); } }
/// <inheritdoc /> public virtual void BeginGeography(OpenGisGeographyType type) { if (_srid < 0) { throw new FormatException($"24300: Expected a call to SetSrid, but BeginGeography({type}) was called."); } _builder.BeginGeo((OGCGeometryType)type); }
public static SqlGeography CreateGeography(this string points, out OpenGisGeographyType geographyType, int srid = 4326) { geographyType = OpenGisGeographyType.Point; SqlGeography firstPoint = null; var pts = points.Trim().Split(new string[] { "\n" }, StringSplitOptions.None).ToList(); pts.Add(null); var b = new SqlGeographyBuilder(); b.SetSrid(srid); b.BeginGeography(OpenGisGeographyType.GeometryCollection); var coordinates = new List <Tuple <double, double> >(); for (int i = 0; i < pts.Count; i++) { if (string.IsNullOrWhiteSpace(pts[i])) { if (coordinates.Count == 1) { if (firstPoint == null) { firstPoint = coordinates[0].CreatePoint(); } b.BeginGeography(OpenGisGeographyType.Point); b.BeginFigure(coordinates[0].Item2, coordinates[0].Item1); b.EndFigure(); b.EndGeography(); } else if (coordinates.Count > 1) { geographyType = OpenGisGeographyType.GeometryCollection; var list = coordinates.Distinct().ToList(); b.BeginGeography(OpenGisGeographyType.Polygon); b.BeginFigure(list[0].Item2, list[0].Item1); for (var j = 1; j < list.Count; j++) { b.AddLine(list[j].Item2, list[j].Item1); } b.AddLine(list[0].Item2, list[0].Item1); b.EndFigure(); b.EndGeography(); } coordinates = new List <Tuple <double, double> >(); continue; } var pt = pts[i].Trim().Split(new string[] { " ", ",", ";", "\t", ":", "\r" }, StringSplitOptions.RemoveEmptyEntries); coordinates.Add(new Tuple <double, double>(double.Parse(pt[0]), double.Parse(pt[1]))); } b.EndGeography(); if (geographyType == OpenGisGeographyType.GeometryCollection) { return(b.ConstructedGeography.EnvelopeAngle() > 90 ? b.ConstructedGeography.ReorientObject() : b.ConstructedGeography); } else { return(firstPoint); } }
public void BeginGeography(OpenGisGeographyType type) { if (_geomCollection == null) { _geomCollection = new SinkGeometryCollection<OpenGisGeographyType>(type); } _currentGeometry = new SinkGeometry<OpenGisGeographyType>(type); }
private void AddGeometryCollection(IGeometry geometry, OpenGisGeographyType type) { builder.BeginGeography(type); IGeometryCollection coll = geometry as IGeometryCollection; Array.ForEach<IGeometry>(coll.Geometries, delegate(IGeometry g) { AddGeometry(g); }); builder.EndGeography(); }
public void EndFigure() { OpenGisGeographyType type = this.types.Peek(); if (type == OpenGisGeographyType.Polygon) { this.rings.Add(this.coordinates.ToArray()); } this.inFigure = false; }
////----------------------------------------------------------------------------------------------------------- public SqlGeography BuildGeography(List <LatLong> points, OpenGisGeographyType type) { SqlGeography geog = null; SqlGeographyBuilder geogBuilder = new SqlGeographyBuilder(); geogBuilder.SetSrid(4326); geogBuilder.BeginGeography(type); LatLong firstLatLong = null; bool firstLatLongStored = false; foreach (LatLong latLong in points) { if (!firstLatLongStored) { firstLatLong = latLong; geogBuilder.BeginFigure(firstLatLong.Latitude, firstLatLong.Longitude); firstLatLongStored = true; } else { geogBuilder.AddLine(latLong.Latitude, latLong.Longitude); } } if (type == OpenGisGeographyType.Polygon) { if (firstLatLong.Latitude != points[points.Count - 1].Latitude && firstLatLong.Longitude != points[points.Count - 1].Longitude) { geogBuilder.AddLine(firstLatLong.Latitude, firstLatLong.Longitude); } } geogBuilder.EndFigure(); geogBuilder.EndGeography(); try { geog = geogBuilder.ConstructedGeography; } catch (Exception ex) { throw; } var invertedGeogrpahy = geog.ReorientObject(); if (geog.STArea() > invertedGeogrpahy.STArea()) { geog = invertedGeogrpahy; } return(geog); }
private void AddGeometryCollection(IGeometry geometry, OpenGisGeographyType type) { builder.BeginGeography(type); IGeometryCollection coll = geometry as IGeometryCollection; Array.ForEach <IGeometry>(coll.Geometries, delegate(IGeometry g) { AddGeometry(g); }); builder.EndGeography(); }
public void BeginGeography(OpenGisGeographyType type) { if (m_depth > 0) { m_sink.BeginGeography(type); } else { Debug.Assert(OpenGisGeographyType.GeometryCollection == type); } m_depth += 1; }
public static SqlGeography Project(this SqlGeometry geometry, Func <IPoint, IPoint> mapFunction, int srid) { var builder = new SqlGeographyBuilder(); builder.SetSrid(srid); geometry = geometry.MakeValid(); OpenGisGeographyType geographyType = (OpenGisGeographyType)Enum.Parse(typeof(OpenGisGeographyType), geometry.STGeometryType().Value, true); builder.BeginGeography(geographyType); switch (geographyType) { case OpenGisGeographyType.Point: ProjectPoint(builder, geometry, mapFunction); break; case OpenGisGeographyType.LineString: ProjectLineString(builder, geometry, mapFunction); break; case OpenGisGeographyType.Polygon: ProjectPolygon(builder, geometry, mapFunction); break; case OpenGisGeographyType.MultiPoint: ProjectMultiPoint(builder, geometry, mapFunction); break; case OpenGisGeographyType.MultiLineString: ProjectMultiLineSring(builder, geometry, mapFunction); break; case OpenGisGeographyType.MultiPolygon: ProjectMultiPolygon(builder, geometry, mapFunction); break; case OpenGisGeographyType.GeometryCollection: case OpenGisGeographyType.CircularString: case OpenGisGeographyType.CompoundCurve: case OpenGisGeographyType.CurvePolygon: case OpenGisGeographyType.FullGlobe: default: throw new NotImplementedException(); } builder.EndGeography(); var result = builder.ConstructedGeography.STIsValid().IsTrue ? builder.ConstructedGeography : builder.ConstructedGeography.MakeValid(); return(result.EnvelopeAngle().Value == 180 ? result.ReorientObject() : result); }
public void BeginGeography(OpenGisGeographyType type) { if (_root) { _root = false; _sink.BeginGeography(type); } else { _types.Enqueue(type); } }
public void BeginGeography(OpenGisGeographyType type) { switch (type) { case OpenGisGeographyType.Polygon: case OpenGisGeographyType.MultiPolygon: case OpenGisGeographyType.Point: break; default: invalidShape = true; break; } CurrentGeography = new List <List <PointF> >(); }
public void BeginGeography(OpenGisGeographyType type) { _types.Push(type); switch (type) { case OpenGisGeographyType.GeometryCollection: case OpenGisGeographyType.MultiPoint: case OpenGisGeographyType.MultiLineString: case OpenGisGeographyType.MultiPolygon: _ccGeometries = new List <IGeometry>(); _ccGeometriesStack.Push(_ccGeometries); break; } }
public void EndGeography() { IGeometry geometry = null; OpenGisGeographyType type = this.types.Pop(); switch (type) { case OpenGisGeographyType.Point: geometry = BuildPoint(); break; case OpenGisGeographyType.LineString: geometry = BuildLineString(); break; case OpenGisGeographyType.Polygon: geometry = BuildPolygon(); break; case OpenGisGeographyType.MultiPoint: geometry = BuildMultiPoint(); break; case OpenGisGeographyType.MultiLineString: geometry = BuildMultiLineString(); break; case OpenGisGeographyType.MultiPolygon: geometry = BuildMultiPolygon(); break; case OpenGisGeographyType.GeometryCollection: geometry = BuildGeometryCollection(); break; } if (this.types.Count == 0) { this.geometry = geometry; this.geometry.SRID = this.srid; } else { this.geometries.Add(geometry); } }
public static SqlGeography CreateGeography(this string points, out OpenGisGeographyType geographyType, int srid = 4326) { geographyType = OpenGisGeographyType.Point; SqlGeography firstPoint = null; var pts = points.Trim().Split(new string[] { "\n" }, StringSplitOptions.None).ToList(); pts.Add(null); var b = new SqlGeographyBuilder(); b.SetSrid(srid); b.BeginGeography(OpenGisGeographyType.GeometryCollection); var coordinates = new List<Tuple<double, double>>(); for (int i = 0; i < pts.Count; i++) { if (string.IsNullOrWhiteSpace(pts[i])) { if (coordinates.Count == 1) { if (firstPoint == null) firstPoint = coordinates[0].CreatePoint(); b.BeginGeography(OpenGisGeographyType.Point); b.BeginFigure(coordinates[0].Item2, coordinates[0].Item1); b.EndFigure(); b.EndGeography(); } else if (coordinates.Count > 1) { geographyType = OpenGisGeographyType.GeometryCollection; var list = coordinates.Distinct().ToList(); b.BeginGeography(OpenGisGeographyType.Polygon); b.BeginFigure(list[0].Item2, list[0].Item1); for (var j = 1; j < list.Count; j++) b.AddLine(list[j].Item2, list[j].Item1); b.AddLine(list[0].Item2, list[0].Item1); b.EndFigure(); b.EndGeography(); } coordinates = new List<Tuple<double, double>>(); continue; } var pt = pts[i].Trim().Split(new string[] { " ", ",", ";", "\t", ":", "\r" }, StringSplitOptions.RemoveEmptyEntries); coordinates.Add(new Tuple<double, double>(double.Parse(pt[0]), double.Parse(pt[1]))); } b.EndGeography(); if (geographyType == OpenGisGeographyType.GeometryCollection) return b.ConstructedGeography.EnvelopeAngle() > 90 ? b.ConstructedGeography.ReorientObject() : b.ConstructedGeography; else return firstPoint; }
public void BeginGeography(OpenGisGeographyType type) { if (type == OpenGisGeographyType.Point || type == OpenGisGeographyType.MultiPoint) { if (_root) { _root = false; _sink.BeginGeography(OpenGisGeographyType.GeometryCollection); _sink.EndGeography(); } _depth++; } else { _root = false; _sink.BeginGeography(type); } }
/// <summary> /// This method will be called when a new geography instance should be passed to the sink /// </summary> /// <param name="type">Geography type</param> public void BeginGeography(OpenGisGeographyType type) { _context.BeginSpatialObject(type); switch (type) { case OpenGisGeographyType.Point: { StartElement("Point"); break; } case OpenGisGeographyType.LineString: { StartElement("LineString"); break; } case OpenGisGeographyType.Polygon: { StartElement("Polygon"); break; } case OpenGisGeographyType.MultiPoint: case OpenGisGeographyType.MultiLineString: case OpenGisGeographyType.MultiPolygon: case OpenGisGeographyType.GeometryCollection: { StartElement("MultiGeometry"); break; } default: { throw new KMLException("Type not supported: " + type.ToString()); } } }
private SpatialType ToSystemSpatialType(OpenGisGeographyType type) { switch (type) { case OpenGisGeographyType.Point: return SpatialType.Point; case OpenGisGeographyType.LineString: return SpatialType.LineString; case OpenGisGeographyType.Polygon: return SpatialType.Polygon; case OpenGisGeographyType.MultiPoint: return SpatialType.MultiPoint; case OpenGisGeographyType.MultiLineString: return SpatialType.MultiLineString; case OpenGisGeographyType.MultiPolygon: return SpatialType.MultiPolygon; case OpenGisGeographyType.GeometryCollection: return SpatialType.Collection; case OpenGisGeographyType.FullGlobe: return SpatialType.FullGlobe; default: return SpatialType.Unknown; } }
public void BeginGeography(OpenGisGeographyType type) { _target.BeginGeography(type); }
public void BeginGeography(OpenGisGeographyType type) { pipeline.BeginGeography(ToSystemSpatialType(type)); }
public void BeginGeography(OpenGisGeographyType type) { m_sink.BeginGeography(type); }
public void BeginGeography(OpenGisGeographyType type) { shapes = new List <MapPoint[]>(); }
public virtual void BeginGeography(OpenGisGeographyType type) => _builder.BeginGeo((OGCGeometryType)type);
public void BeginGeography(OpenGisGeographyType type) { _sink.BeginGeography(type); _insideLineString = type == OpenGisGeographyType.LineString; }
public void BeginGeography(OpenGisGeographyType type) { _builder.BeginGeometry((OpenGisGeometryType)type); }
public void BeginGeography(OpenGisGeographyType type) { // Convert geography to geometry types... _target.BeginGeometry((OpenGisGeometryType)type); }
public void BeginGeography(OpenGisGeographyType type) { this.types.Push(type); }
public void BeginGeography(OpenGisGeographyType type) { this.types.Push(type); }
public void BeginGeography(OpenGisGeographyType type) { _sink.BeginGeography(type); _insidePolygon = type == OpenGisGeographyType.Polygon; }
public void BeginGeography(OpenGisGeographyType type) { _types.Push(type); switch (type) { case OpenGisGeographyType.GeometryCollection: case OpenGisGeographyType.MultiPoint: case OpenGisGeographyType.MultiLineString: case OpenGisGeographyType.MultiPolygon: _ccGeometries = new List<IGeometry>(); _ccGeometriesStack.Push(_ccGeometries); break; } }
public void BeginGeography(OpenGisGeographyType type) { _sink.BeginGeometry((OpenGisGeometryType)type); }
public void BeginGeography(OpenGisGeographyType type) { pipeline.BeginGeography(ToSystemSpatialType(type)); }
private void AddGeometryCollection(SqlGeographyBuilder builder, IGeometry geometry, OpenGisGeographyType type) { builder.BeginGeography(type); var coll = geometry as IGeometryCollection; Debug.Assert(coll != null, "coll != null"); Array.ForEach(coll.Geometries, geometry1 => AddGeometry(builder, geometry1)); builder.EndGeography(); }