public void CanCompareWGSPointNonequal() { var point1 = new WGSPoint(10, 10); var point2 = new WGSPoint(11, 10); Assert.True(point1 != point2); }
private static double ComputeSquaredDistance(WGSPoint firstPoint, WGSPoint lastPoint) { double d1 = firstPoint.Lon - lastPoint.Lon; double d2 = firstPoint.Lat - lastPoint.Lat; return(d1 * d1 + d2 * d2); }
private void CheckForCoordinate(WGSPoint coordinate) { if (coordinate == null) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError, "No WGS84 coordinates provided")); } }
public void MapWGSPointToFencePoint() { var point = new WGSPoint(123.4, 567.8); var fencePoint = AutoMapperUtility.Automapper.Map <FencePoint>(point); Assert.Equal(point.Lon, fencePoint.X); Assert.Equal(point.Lat, fencePoint.Y); Assert.Equal(0, fencePoint.Z); }
public void MapWGSPointToXYZ() { var llPoint = new WGSPoint(1.234, 5.678); var xyz = AutoMapperUtility.Automapper.Map <XYZ>(llPoint); Assert.Equal(llPoint.Lat, xyz.Y); Assert.Equal(llPoint.Lon, xyz.X); Assert.Equal(0, xyz.Z); }
/// <summary> /// Compute the cross product AB x AC /// </summary> private static double ComputeCrossProduct(WGSPoint firstPoint, WGSPoint lastPoint, WGSPoint currentPoint) { double abx = lastPoint.Lon - firstPoint.Lon; double aby = lastPoint.Lat - firstPoint.Lat; double acx = currentPoint.Lon - firstPoint.Lon; double acy = currentPoint.Lat - firstPoint.Lat; double cross = abx * acy - aby * acx; return(cross); }
/// <summary> /// Compute the dot product AB . AC /// </summary> private static double ComputeDotProduct(WGSPoint firstPoint, WGSPoint lastPoint, WGSPoint currentPoint) { double abx = lastPoint.Lon - firstPoint.Lon; double aby = lastPoint.Lat - firstPoint.Lat; double bcx = currentPoint.Lon - lastPoint.Lon; double bcy = currentPoint.Lat - lastPoint.Lat; double dot = abx * bcx + aby * bcy; return(dot); }
public CellPassesTRexRequest( Guid projectUid, WGSPoint llPoint, FilterResult filter, OverridingTargets overrides, LiftSettings liftSettings) : this(projectUid, filter, overrides, liftSettings) { LLPoint = llPoint; CoordsAreGrid = false; }
/// <summary> /// Uses the Douglas Peucker alogrithm to reduce a polyline to a specifc number of points. /// </summary> public static List <double[]> DouglasPeuckerByCount(double[,] coordinates, int maxVertexLimit) { var pointCount = coordinates.GetLength(0); var wgsPointArray = new WGSPoint[pointCount]; for (var i = 0; i < pointCount; i++) { wgsPointArray[i] = new WGSPoint(coordinates[i, 1], coordinates[i, 0]); } return(DouglasPeuckerByCount(wgsPointArray, maxVertexLimit)); }
/// <summary> /// Create instance of CellPassRequest /// </summary> public static CellPassesRequest CreateCellPassRequest(long projectId, CellAddress cellAddress, Point probePositionGrid, WGSPoint probePositionLL, LiftBuildSettings liftBuildSettings, int gridDataType, long filterId, FilterResult filter) { return(new CellPassesRequest { ProjectId = projectId, cellAddress = cellAddress, probePositionGrid = probePositionGrid, probePositionLL = probePositionLL, liftBuildSettings = liftBuildSettings, gridDataType = gridDataType, filterId = filterId, filter = filter }); }
public void CPR_CanCreateCellPassesRequestTest() { var liftThicknessTarget = new LiftThicknessTarget { AboveToleranceLiftThickness = (float)0.001, BelowToleranceLiftThickness = (float)0.002, TargetLiftThickness = (float)0.05 }; var validator = new DataAnnotationsValidator(); CellPassesRequest cpRequest = CellPassesRequest.CreateCellPassRequest(544, null, null, null, null, 0, 0, null); Assert.IsTrue(validator.TryValidate(cpRequest, out ICollection <ValidationResult> results)); // invalid projectid cpRequest = CellPassesRequest.CreateCellPassRequest(-1, null, null, null, null, 0, 0, null); Assert.IsFalse(validator.TryValidate(cpRequest, out results)); // full data CellAddress cellAddress = CellAddress.CreateCellAddress(1, 2); Point point = Point.CreatePoint(1.0, 2.0); WGSPoint wgsPoint = new WGSPoint(1.0, 2.0); LiftBuildSettings settings = new LiftBuildSettings( new CCVRangePercentage(30.0, 70.0), false, 0.0, 0.0, 0.2f, LiftDetectionType.Automatic, LiftThicknessType.Compacted, new MDPRangePercentage(35.0, 75.0), false, 0.0f, 0, 0, null, null, null, liftThicknessTarget, null); var filterResult = FilterResult.CreateFilterObsolete(null, null, null, null, null, null, 1, "", new List <long>(), true, false, null, new List <WGSPoint>(), new List <Point>(), false, new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0), 0, 0, 0, 0, null, new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0), 0, 0, 0, new List <MachineDetails>(), new List <long>(), false, GPSAccuracyType.Medium, false, null, null, null, new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0)); cpRequest = CellPassesRequest.CreateCellPassRequest(544, cellAddress, point, wgsPoint, settings, 0, 0, filterResult); Assert.IsTrue(validator.TryValidate(cpRequest, out results)); }
public CellDatumRequest( long projectId, Guid?projectUid, DisplayMode displayMode, WGSPoint llPoint, Point gridPoint, FilterResult filter, LiftBuildSettings liftBuildSettings, DesignDescriptor design) { ProjectId = projectId; ProjectUid = projectUid; DisplayMode = displayMode; LLPoint = llPoint; GridPoint = gridPoint; Filter = filter; FilterId = filter?.Id ?? -1; LiftBuildSettings = liftBuildSettings; Design = design; }
/// <summary> /// Returns polygons from wkt. Only returns unique ones (i.e 1st and last are not the same) /// </summary> private static List <WGSPoint> GetPointsFromWkt(string wkt) { List <WGSPoint> ret = new List <WGSPoint>(); try { wkt = wkt.ToUpper(); string prefix = "POLYGON"; if (wkt.StartsWith(prefix) && (prefix.Length < wkt.Length)) { //extract x from POLYGON (x) or POLYGON(lon1 lat1, lon2 lat2) string relevant = wkt.Substring(prefix.Length, wkt.Length - prefix.Length).Trim(' ').Trim('(', ')'); //relevant will be lon1 lat1,lon2 lat2 ... var pairs = relevant.Split(',').Select(x => x.Trim()).ToList(); var first = pairs.First(); var last = pairs.Last(); if (!first.Equals(last)) { return(new List <WGSPoint>()); } foreach (var pair in pairs.Take(pairs.Count - 1)) { string[] vals = pair.Split(' '); if (vals.Length == 2) { string longitude = vals[0].Substring(vals[0].StartsWith("(") ? 1 : 0); //remove prefix ( if present string latitude = vals[1].Substring(0, vals[1].Length - (vals[1].EndsWith(")") ? 1 : 0)); // remove suffix ) if present var pt = new WGSPoint(Convert.ToDouble(latitude), Convert.ToDouble(longitude)); ret.Add(pt); } } } } catch (Exception) { return(ret); } return(ret); }
public static void ConvertProfileEndPositions(ProfileGridPoints gridPoints, ProfileLLPoints lLPoints, out WGSPoint startPt, out WGSPoint endPt, out bool positionsAreGrid) { if (gridPoints != null) { positionsAreGrid = true; startPt = new WGSPoint(gridPoints.y1, gridPoints.x1); endPt = new WGSPoint(gridPoints.y2, gridPoints.x2); } else if (lLPoints != null) { positionsAreGrid = false; startPt = new WGSPoint(lLPoints.lat1, lLPoints.lon1); endPt = new WGSPoint(lLPoints.lat2, lLPoints.lon2); } else { throw ThrowNoProfileLineDefinedException(); } }
/// <summary> /// Overload constructor with parameters. /// </summary> public CellDatumTRexRequest( Guid projectUid, DisplayMode displayMode, WGSPoint llPoint, Point gridPoint, FilterResult filter, Guid?designUid, double?offset, OverridingTargets overrides, LiftSettings liftSettings) { ProjectUid = projectUid; DisplayMode = displayMode; LLPoint = llPoint; GridPoint = gridPoint; Filter = filter; DesignUid = designUid; Offset = offset; Overrides = overrides; LiftSettings = liftSettings; }
private TCoordPointList GetGridCoordinates(long projectId, WGSPoint latLon) { var latLongs = new TWGS84FenceContainer { FencePoints = new [] { RaptorConverters.ConvertWGSPoint(latLon) } }; var code = raptorClient.GetGridCoordinates ( projectId, latLongs, TCoordConversionType.ctLLHtoNEE, out var pointList ); if (code != TCoordReturnCode.nercNoError || pointList.Points.Coords == null || pointList.Points.Coords.Length == 0) { throw CreateServiceException <CompactionCellDatumExecutor>((int)code); } return(pointList); }
/// <summary> /// Compute the distance from AB to C. /// If isSegment is true, AB is a segment, not a line. /// </summary> private static double LineToPointDistance2D(WGSPoint firstPoint, WGSPoint lastPoint, WGSPoint currentPoint, bool isSegment) { double dist = ComputeCrossProduct(firstPoint, lastPoint, currentPoint) / ComputeDistance(firstPoint, lastPoint); if (isSegment) { double dot1 = ComputeDotProduct(firstPoint, lastPoint, currentPoint); if (dot1 > 0) { return(ComputeDistance(lastPoint, currentPoint)); } double dot2 = ComputeDotProduct(lastPoint, firstPoint, currentPoint); if (dot2 > 0) { return(ComputeDistance(firstPoint, currentPoint)); } } return(Math.Abs(dist)); }
/// <summary> /// Compute the distance from A to B /// </summary> private static double ComputeDistance(WGSPoint firstPoint, WGSPoint lastPoint) => Math.Sqrt(ComputeSquaredDistance(firstPoint, lastPoint));