Mercurial > postarc > postarc
diff Postarc/Postarc/Feature/Point.cs @ 0:1aca3d413885 tip
Initial import of Postarc
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 05 Oct 2012 23:55:06 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Postarc/Postarc/Feature/Point.cs Fri Oct 05 23:55:06 2012 +0200 @@ -0,0 +1,419 @@ +/* + * Postarc + * + * Author: + * Christian Lins <christian.lins@intevation.de> + * + * Copyright: + * Copyright (C) 2012 Intevation GmbH <http://www.intevation.de/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ESRI.ArcGIS.Geometry; +using NpgsqlTypes; +using System.Globalization; +using ESRI.ArcGIS.Geodatabase; +using System.Diagnostics; +using ESRI.ArcGIS.esriSystem; + +namespace Postarc.Feature +{ + public class Point : + IWKTGeometry, + IGeometryDef, + IPoint, + IGeometry, + IGeometry2, + IGeometry3, + IGeometry4, + IGeometry5, + IClone, + IConstructPoint, + IConstructPoint2 + { + protected PointClass point = new PointClass(); + + public double X + { + get + { + return this.point.X; + } + set + { + this.point.X = value; + } + } + + public double Y + { + get + { + return this.point.Y; + } + set + { + this.point.Y = Y; + } + } + + public double Z + { + get + { + return point.Z; + } + set + { + this.point.Z = value; + } + } + + public Point() + { + this.point.SpatialReference = FeatureLayer.CreateGeographicSpatialReference(); + this.point.PutCoords(0, 0); + } + + public Point(IPoint point) + { + this.point.SpatialReference = point.SpatialReference; + this.point.PutCoords(point.X, point.Y); + } + + /// <summary> + /// Compares X, Y, M, Z, ID (in order) of this point with + /// otherPoint's respective values. + /// </summary> + /// <param name="otherPoint"></param> + /// <returns> + /// 0 if equal, 1 if this point is greater, -1 if smaller + /// </returns> + public int Compare(IPoint otherPoint) + { + return this.point.Compare(otherPoint); + } + + public void ConstrainAngle(double constraintAngle, IPoint anchor, bool allowOpposite) + { + this.point.ConstrainAngle(constraintAngle, anchor, allowOpposite); + } + + public void ConstrainDistance(double constraintRadius, IPoint anchor) + { + this.point.ConstrainDistance(constraintRadius, anchor); + } + + public esriGeometryDimension Dimension + { + get + { + // A point has no dimension + return this.point.Dimension; + } + } + + /// <summary> + /// Creates and returns an envelope of this point. + /// </summary> + public IEnvelope Envelope + { + get + { + return this.point.Envelope; + } + } + + public void GeoNormalize() + { + this.point.GeoNormalize(); + } + + public void GeoNormalizeFromLongitude(double longitude) + { + this.point.GeoNormalizeFromLongitude(longitude); + } + + public esriGeometryType GeometryType + { + get + { + return esriGeometryType.esriGeometryPoint; + } + } + + public int ID + { + get + { + return this.point.ID; + } + set + { + this.point.ID = value; + } + } + + public bool IsEmpty + { + get + { + return this.point.IsEmpty; + } + } + + public double M + { + get + { + return this.point.M; + } + set + { + this.point.M = value; + } + } + + public void Project(ISpatialReference newReferenceSystem) + { + this.point.Project(newReferenceSystem); + } + + public void PutCoords(double X, double Y) + { + this.point.X = X; + this.point.Y = Y; + } + + public void QueryCoords(out double X, out double Y) + { + X = this.X; + Y = this.Y; + } + + public void SetEmpty() + { + this.point.X = 0; + this.point.Y = 0; + } + + public void SnapToSpatialReference() + { + this.point.SnapToSpatialReference(); + } + + public ISpatialReference SpatialReference + { + get + { + return this.point.SpatialReference; + } + set + { + Debug.WriteLine("Point::SpatialReference::set"); + this.point.SpatialReference = value; + } + } + + public double get_VertexAttribute(esriGeometryAttributes attributeType) + { + return this.point.get_VertexAttribute(attributeType); + } + + public void set_VertexAttribute(esriGeometryAttributes attributeType, double attributeValue) + { + this.point.set_VertexAttribute(attributeType, attributeValue); + } + + public string GetWKT() + { + StringBuilder wkt = new StringBuilder(); + wkt.Append("POINT("); + wkt.Append(X.ToString("r", CultureInfo.InvariantCulture)); + wkt.Append(" "); + wkt.Append(Y.ToString("r", CultureInfo.InvariantCulture)); + wkt.Append(")"); + return wkt.ToString(); + } + + public int AvgNumPoints + { + get + { + return 1; + } + } + + public int GridCount + { + get + { + return 0; + } + } + + public bool HasM + { + get + { + return false; + } + } + + public bool HasZ + { + get + { + return false; + } + } + + public double get_GridSize(int index) + { + return 0; + } + + + public void SetWKT(string wkt) + { + wkt = wkt.Split(new char[] { '(', ')' })[1]; + string[] wkts = wkt.Split(' '); + X = double.Parse(wkts[0]); + Y = double.Parse(wkts[1]); + } + + + public void QueryEnvelope(IEnvelope outEnvelope) + { + this.point.QueryEnvelope(outEnvelope); + } + + public IPoint CentroidEx + { + get { throw new NotImplementedException(); } + } + + public bool Changed + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public void Project5(ISpatialReference newSpatialReference, int ProjectionHint) + { + throw new NotImplementedException(); + } + + public void ProjectEx(ISpatialReference newReferenceSystem, esriTransformDirection direction, IGeoTransformation GeoTransformation, bool bAngularDensify, double maxSegmentLength, double maxDeviation) + { + throw new NotImplementedException(); + } + + public void ProjectEx5(ISpatialReference newReferenceSystem, esriTransformDirection direction, ITransformation transformation, bool bAngularDensify, double maxSegmentLength, double maxDeviation, int ProjectionHint) + { + throw new NotImplementedException(); + } + + public void QueryWKSEnvelope(out ESRI.ArcGIS.esriSystem.WKSEnvelope e) + { + throw new NotImplementedException(); + } + + public void Assign(IClone src) + { + throw new NotImplementedException(); + } + + public IClone Clone() + { + throw new NotImplementedException(); + } + + public bool IsEqual(IClone other) + { + throw new NotImplementedException(); + } + + public bool IsIdentical(IClone other) + { + throw new NotImplementedException(); + } + + public void ConstructAlong(ICurve curve, esriSegmentExtension extension, double distance, bool asRatio) + { + throw new NotImplementedException(); + } + + public void ConstructAngleBisector(IPoint from, IPoint through, IPoint to, double distance, bool useAcuteAngle) + { + throw new NotImplementedException(); + } + + public void ConstructAngleDistance(IPoint p, double inAngle, double distance) + { + throw new NotImplementedException(); + } + + public void ConstructAngleIntersection(IPoint p1, double angle1, IPoint p2, double angle2) + { + throw new NotImplementedException(); + } + + public void ConstructAverage(IPointCollection Points, esriGeometryAttributes attributeType) + { + throw new NotImplementedException(); + } + + public void ConstructDeflection(ILine baseLine, double distance, double inAngle) + { + throw new NotImplementedException(); + } + + public void ConstructDeflectionIntersection(ILine baseLine, double startAngle, double endAngle, bool OnRightSide) + { + throw new NotImplementedException(); + } + + public void ConstructOffset(ICurve curve, esriSegmentExtension extension, double distance, bool asRatio, double Offset) + { + throw new NotImplementedException(); + } + + public void ConstructParallel(ISegment Segment, esriSegmentExtension extension, IPoint start, double distance) + { + throw new NotImplementedException(); + } + + public void ConstructPerpendicular(ISegment @base, esriSegmentExtension extension, IPoint p, double distance, bool bUseLineOrientation) + { + throw new NotImplementedException(); + } + + public void ConstructThreePointResection(IPoint point1, double angleP1P2, IPoint point2, double angleP2P3, IPoint point3, out double arcAngle) + { + throw new NotImplementedException(); + } + } +}