public DerivedPointDto DeriveLocation(SuppliedPointDto startPoint, double bearing, double distance)
        {
            Angle             azimuth         = new Angle(bearing);
            Angle             startLatitude   = new Angle(startPoint.Latitude);
            Angle             startLongitude  = new Angle(startPoint.Longitude);
            GlobalCoordinates startCoordinate = new GlobalCoordinates(startLatitude, startLongitude);
            GlobalCoordinates endCoordinate   = this.calculator.CalculateEndingGlobalCoordinates(startCoordinate, azimuth, distance);
            DerivedPointDto   derived         = new DerivedPointDto(endCoordinate.Latitude.Degrees, endCoordinate.Longitude.Degrees);

            return(derived);
        }
Exemple #2
0
        public IList <DerivedPointDto> CreateArc(double radius, SuppliedPointDto centerPoint, SuppliedPointDto startPoint, SuppliedPointDto endPoint)
        {
            Angle centerLatitude  = new Angle(centerPoint.Latitude);
            Angle centerLongitude = new Angle(centerPoint.Longitude);
            Angle startLatitude   = new Angle(startPoint.Latitude);
            Angle startLongitude  = new Angle(startPoint.Longitude);
            Angle endLatitude     = new Angle(endPoint.Latitude);
            Angle endLongitude    = new Angle(endPoint.Longitude);

            GlobalCoordinates centerCoordinate = new GlobalCoordinates(centerLatitude, centerLongitude);
            GlobalCoordinates startCoordinate  = new GlobalCoordinates(startLatitude, startLongitude);
            GlobalCoordinates endCoordinate    = new GlobalCoordinates(endLatitude, endLongitude);

            GlobalPosition centerPosition = new GlobalPosition(centerCoordinate);
            GlobalPosition startPosition  = new GlobalPosition(startCoordinate);
            GlobalPosition endPosition    = new GlobalPosition(endCoordinate);

            GeodeticMeasurement centerToStartMeasurement = calculator.CalculateGeodeticMeasurement(centerPosition, startPosition);
            GeodeticMeasurement centerToEndMeasurement   = calculator.CalculateGeodeticMeasurement(centerPosition, endPosition);

            // Radius should ensure that it is tolerable (we are going to ingore it in this implementation)
            double startDistance   = centerToStartMeasurement.PointToPointDistance;
            double endDistance     = centerToEndMeasurement.PointToPointDistance;
            double distanceDelta   = Math.Abs(startDistance - endDistance);
            double distanceEpsilon = distanceDelta / 10;

            Angle startBearing = centerToStartMeasurement.Azimuth;
            Angle endBearing   = centerToEndMeasurement.Azimuth;

            double degreesDelta   = Math.Abs(startBearing.Degrees - endBearing.Degrees);
            double degreesEpsilon = degreesDelta / 10;  // Our angular distribution

            IList <DerivedPointDto> arcPoints = new List <DerivedPointDto>();

            // We are going to assume that arc derivation is done in a clockwise position.
            for (int i = 0; i < 10; i++) // Such that the 10th increment should equate to the end point and the initial the start
            {
                Angle             nextBearing   = new Angle(startBearing.Degrees + (degreesEpsilon * (i + 1)));
                GlobalCoordinates thetaLocation = calculator.CalculateEndingGlobalCoordinates(centerCoordinate, nextBearing, startDistance + (distanceEpsilon * (i + 1)));
                DerivedPointDto   thetaPoint    = new DerivedPointDto(thetaLocation.Latitude.Degrees, thetaLocation.Longitude.Degrees);

                arcPoints.Add(thetaPoint);
            }

            return(arcPoints);
        }
        public IGeometry BuildEsa(double radius, double latitude, double longitude)
        {
            SuppliedPointDto centerPoint       = new SuppliedPointDto(latitude, longitude);
            DerivedPointDto  startPointDerived = this.locationDerivation.DeriveLocation(centerPoint, 0, radius);
            DerivedPointDto  endPointDerived   = this.locationDerivation.DeriveLocation(centerPoint, 180, radius);
            SuppliedPointDto startPoint        = new SuppliedPointDto(startPointDerived);
            SuppliedPointDto endPoint          = new SuppliedPointDto(endPointDerived);


            IList <DerivedPointDto> derivedRightArc = this.arcDerivation.CreateArc(radius, centerPoint, startPoint, endPoint);
            IList <DerivedPointDto> derivedLeftArc  = this.arcDerivation.CreateArc(radius, centerPoint, endPoint, startPoint);
            IList <DerivedPointDto> derivedCircle   = derivedRightArc.Concat(derivedLeftArc).ToList();

            derivedCircle.Add(derivedCircle.First());   // Force closure

            IList <Coordinate> coordinates = new List <Coordinate>();

            foreach (DerivedPointDto point in derivedCircle)
            {
                coordinates.Add(new Coordinate(point.Longitude, point.Latitude));
            }

            return(new Polygon(new LinearRing(coordinates.ToArray())));
        }
Exemple #4
0
 public IList <DerivedPointDto> CreateArc(double radius, SuppliedPointDto centerPoint, double startBearing, double endBearing)
 {
     throw new NotImplementedException();
 }