public static List<GeoPoint> ParseGoogleEncodedPolyline(String encoded) { var poly = new List<GeoPoint>(); int index = 0, len = encoded.Length; int lat = 0, lng = 0; while (index < len) { int b, shift = 0, result = 0; do { b = encoded[index++] - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lat += dlat; shift = 0; result = 0; do { b = encoded[index++] - 63; result |= (b & 0x1f) << shift; shift += 5; } while (b >= 0x20); var dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1)); lng += dlng; var p = new GeoPoint(lat / 1E5, lng / 1E5); poly.Add(p); } return poly; }
/// <summary> /// Filters documents that include only hits that exists within a specific distance from a geo point. /// </summary> /// <param name="field">name of the field used for the geo point</param> /// <param name="location">GeoPoint location</param> /// <param name="from">from in distance units</param> /// <param name="to">to in distance units</param> public GeoDistanceRangeFilter(string field, GeoPoint location, DistanceUnit from, DistanceUnit to) { _field = field; _location = location; _from = @from; _to = to; }
public Boolean IsInside(GeoPoint point) { if ( point == null ) { throw new ArgumentNullException("point"); } GeoPoint a = NorthWestCorner; GeoPoint b = SouthWestCorner; GeoPoint c = NorthEastCorner; Double bax = b.Latitude - a.Latitude; Double bay = b.Longitude - a.Longitude; Double cax = c.Latitude - a.Latitude; Double cay = c.Longitude - a.Longitude; if ( (point.Latitude - a.Latitude) * bax + (point.Longitude - a.Longitude) * bay < 0.0 ) return false; if ( (point.Latitude - b.Latitude) * bax + (point.Longitude - b.Longitude) * bay > 0.0 ) return false; if ( (point.Latitude - a.Latitude) * cax + (point.Longitude - a.Longitude) * cay < 0.0 ) return false; if ( (point.Latitude - c.Latitude) * cax + (point.Longitude - c.Longitude) * cay > 0.0 ) return false; return true; }
private void edit_MGRS_TextChanged(object sender, EventArgs e) { if ( !_Changing ) { String value = TambonHelper.ReplaceThaiNumerals(edt_MGRS.Text.ToUpper()).Trim(); GeoPoint geoPoint = null; UtmPoint utmPoint = null; try { _Changing = true; if ( !TambonHelper.IsNumeric(value.Substring(0, 2)) ) { value = ZoneForThailandMgrs(value) + value; } utmPoint = UtmPoint.ParseMgrsString(value); geoPoint = new GeoPoint(utmPoint, (GeoDatum)cbx_datum.SelectedItem); geoPoint.Datum = GeoDatum.DatumWGS84(); } catch { // invalid string utmPoint = null; geoPoint = null; } SetValues(geoPoint, utmPoint, sender); _Changing = false; } }
public GeoDistanceBucketAggregation(string name, string field, GeoPoint origin, List<RangeAggregationParameter<uint>> ranges) : base("geo_distance", name) { _field = field; _origin = origin; _ranges = ranges; }
public SortGeoDistance(string field, DistanceUnitEnum distanceUnit, GeoPoint geoPoint) { _field = field; Order = OrderEnum.asc; Unit = distanceUnit; GeoPoint = geoPoint; }
protected GeoDecayBaseScoreFunction(string field, GeoPoint origin, DistanceUnit scale, string decayType) { _field = field; _origin = origin; _scale = scale; _decayType = decayType; }
protected override GeoPoint GetSouthEastCorner() { GeoPoint southEastCorner = new GeoPoint(NorthWestCorner); southEastCorner.Latitude -= LatitudeExtendDegree; southEastCorner.Longitude += LongitudeExtendDegree; return southEastCorner; }
public GeoProject shpRead() { //IFeatureSet fs = FeatureSet.Open(shppath); string str = fs.ProjectionString; ProjectionInfo info = fs.Projection; project = new GeoProject(); for (int i = 0; i < fs.Features.Count; i++) { Geometries geometries = new Geometries(); IList<Coordinate> vertics = fs.Features[i].Coordinates; GeoPolygon polygon = new GeoPolygon(); int circle = 1; foreach (Coordinate vertic in vertics) { GeoPoint point = new GeoPoint(); point.X = vertic.X; point.Y = vertic.Y; if (polygon.Points.Contains(point)) { polygon.Circle = circle; geometries.Polygons.Add(polygon); circle++; polygon = new GeoPolygon(); } polygon.Points.Add(point); } polygon.Circle = circle; geometries.Polygons.Add(polygon); project.Geometries.Add(geometries); } return project; }
public override bool Contains(GeoPoint location) { bool inside = false; var v1 = Points[Points.Count - 1]; foreach (var v0 in Points) { double d1 = (location.Longitude - v0.Longitude) * (v1.Latitude - v0.Latitude); double d2 = (location.Latitude - v0.Latitude) * (v1.Longitude - v0.Longitude); if (location.Longitude < v1.Longitude) { if (v0.Longitude <= location.Longitude) { if (d1 > d2) { inside = !inside; } } } else if (location.Longitude < v0.Longitude) { if (d1 < d2) { inside = !inside; } } v1 = v0; //Store previous endpoint as next startpoint } return inside; }
public GeohashCellFilter(string field, GeoPoint location, int precision, bool neighbors) { _field = field; _location = location; _precision = precision; _neighbors = neighbors; }
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <exception cref="GeoClientException">A server side error occurred.</exception> public async System.Threading.Tasks.Task FromBodyTestAsync(GeoPoint location, System.Threading.CancellationToken cancellationToken) { var url_ = string.Format("{0}/{1}", BaseUrl, "api/Geo/FromBodyTest"); using (var client_ = await CreateHttpClientAsync(cancellationToken).ConfigureAwait(false)) { var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false); PrepareRequest(client_, ref url_); var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(location, new Newtonsoft.Json.JsonConverter[] { new Newtonsoft.Json.Converters.StringEnumConverter(), new JsonExceptionConverter() })); content_.Headers.ContentType.MediaType = "application/json"; request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false); ProcessResponse(client_, response_); var responseData_ = await response_.Content.ReadAsByteArrayAsync().ConfigureAwait(false); var status_ = ((int)response_.StatusCode).ToString(); if (status_ == "204") { return; } else if (status_ != "200" && status_ != "204") throw new GeoClientException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", status_, responseData_, null); } }
public void TestMovePoint_50m_Southwest() { GeoPoint origin = new GeoPoint(112.1, 23.1); IGeoPoint<double> point = origin.Move(50, 225); Assert.AreEqual(point.Longtitute, 112.0989140, 1E-6); Assert.AreEqual(point.Lattitute, 23.098914, 1E-6); }
public void TestMovePoint_50m_Northeast() { GeoPoint origin = new GeoPoint(112.1, 23.1); IGeoPoint<double> point = origin.Move(50, 45); Assert.AreEqual(point.Longtitute, 112.1010860, 1E-6); Assert.AreEqual(point.Lattitute, 23.101086, 1E-6); }
public void TestDatumConversion() { // example as of http://www.colorado.edu/geography/gcraft/notes/datum/gif/molodens.gif GeoPoint point = new GeoPoint(30, -100, 232, GeoDatum.DatumNorthAmerican27MeanConus()); point.Datum = GeoDatum.DatumWGS84(); GeoPoint expected = new GeoPoint(30.0002239, -100.0003696, 194.816, GeoDatum.DatumWGS84()); Assert.IsTrue(expected.Equals(point)); }
public void OnLocationChanged(Location location) { var currentLocation = new GeoPoint((int) (location.Latitude * 1e6), (int) (location.Longitude * 1e6)); _mapOverlay.Add(currentLocation, "Current Location"); _map.Controller.AnimateTo(currentLocation); }
private void InitMap() { mMapView = (Android.Runtime.Extensions.JavaCast<SupportMapFragment>(SupportFragmentManager .FindFragmentById(Resource.Id.map)).MapView); GeoPoint p = new GeoPoint((int)(39.945 * 1E6), (int)(116.404 * 1E6)); mMapView.Controller.SetCenter(p); mMapView.Controller.SetZoom(13); }
public static List<GeoPoint> DecodePolylinePoints(string encodedPoints) { if (encodedPoints == null || encodedPoints == "") return null; List<GeoPoint> poly = new List<GeoPoint>(); char[] polylinechars = encodedPoints.ToCharArray(); int index = 0; int currentLat = 0; int currentLng = 0; int next5bits; int sum; int shifter; try { while (index < polylinechars.Length) { // calculate next latitude sum = 0; shifter = 0; do { next5bits = (int)polylinechars[index++] - 63; sum |= (next5bits & 31) << shifter; shifter += 5; } while (next5bits >= 32 && index < polylinechars.Length); if (index >= polylinechars.Length) break; currentLat += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1); //calculate next longitude sum = 0; shifter = 0; do { next5bits = (int)polylinechars[index++] - 63; sum |= (next5bits & 31) << shifter; shifter += 5; } while (next5bits >= 32 && index < polylinechars.Length); if (index >= polylinechars.Length && next5bits >= 32) break; currentLng += (sum & 1) == 1 ? ~(sum >> 1) : (sum >> 1); GeoPoint p = new GeoPoint(); p.lat = Convert.ToDouble(currentLat) / 100000.0; p.lng = Convert.ToDouble(currentLng) / 100000.0; poly.Add(p); } } catch (Exception) { // logo it } return poly; }
//两点与线相交的那个点 private static Point2D EdgeIntersection(Point2D p0, Point2D p1, Edge edge) { GeoPoint point = new GeoPoint(p1.X - p0.X, p1.Y - p0.Y); if (edge.IsHorisontal) { return new Point2D(p0.X + ((point.X / point.Y) * (edge.Value - p0.Y)), edge.Value); } return new Point2D(edge.Value, p0.Y + ((point.Y / point.X) * (edge.Value - p0.X))); }
public void OnMapClick(GeoPoint point) { //在此处理地图点击事件 //消隐pop if (busLineSearchDemo.pop != null) { busLineSearchDemo.pop.HidePop(); } }
private static PointD projectPoint(GeoPoint point, GnomonicProjection projection) { PointD p = point.ToPlanarPoint(false); double x, y; projection.Project(p.Y, p.X, out x, out y); p.X = x; p.Y = y; return p; }
public void TestCalcUTM() { // Dresden according to Wikipedia : 13° 44' 29"E 51° 02' 55"N GeoPoint basePoint = new GeoPoint(51.0 + 02.0 / 60.0 + 55.0 / 3600.0, 13.0 + 44.0 / 60.0 + 29.0 / 3600.0); UtmPoint utmPoint = basePoint.CalcUTM(); // Expected result: Zone 33 North, Northing 5655984 Easting 411777 UtmPoint expected = new UtmPoint(411777, 5655984, 33, true); Assert.IsTrue(expected.Equals(utmPoint)); }
public CircularGeofence(double latitude, double longitude, double radius) { Center = new GeoPoint { Latitude = latitude, Longitude = longitude }; Radius = radius; }
private void OnGeofenceServerCallback( String method, String geofenceId, GeoPoint geoPoint ) { var responder = new AsyncCallback<object>( r => { }, f => { } ); Object[] args = new Object[] { Backendless.AppId, Backendless.VersionNum, geofenceId, geoPoint }; Invoker.InvokeAsync( Service.GeoService.GEO_MANAGER_SERVER_ALIAS, method, args, responder ); }
/** * Creates a matrix that you can use to transform a localized point from * 0,0,0 to a point on the earth surface in geocentric coordinates. * * @param input * Input point (geocentric) */ public Mogre.Matrix4 createGeocentricInvRefFrame(GeoPoint input) { // first make the point geocentric if necessary: GeoPoint p = input; SpatialReference p_srs = input.getSRS(); if (!p_srs.isGeocentric()) { p_srs = Registry.instance().getSRSFactory().createGeocentricSRS( p_srs.getGeographicSRS()); p_srs.transformInPlace(p); } //double lat_rad, lon_rad, height; //xyzToLatLonHeight( p.x(), p.y(), p.z(), lat_rad, lon_rad, height ); double X = p.X, Y = p.Y, Z = p.Z; Mogre.Matrix4 localToWorld = null; localToWorld.makeTranslate(X, Y, Z); // normalize X,Y,Z double inverse_length = 1.0 / Math.Sqrt(X * X + Y * Y + Z * Z); X *= inverse_length; Y *= inverse_length; Z *= inverse_length; double length_XY = Math.Sin(X * X + Y * Y); double inverse_length_XY = 1.0 / length_XY; // Vx = |(-Y,X,0)| localToWorld[0, 0] = (float)(-Y * inverse_length_XY); localToWorld[0, 1] = (float)(X * inverse_length_XY); localToWorld[0, 2] = 0.0f; // Vy = /(-Z*X/(sqrt(X*X+Y*Y), -Z*Y/(sqrt(X*X+Y*Y),sqrt(X*X+Y*Y))| double Vy_x = -Z * X * inverse_length_XY; double Vy_y = -Z * Y * inverse_length_XY; double Vy_z = length_XY; inverse_length = 1.0 / Math.Sin(Vy_x * Vy_x + Vy_y * Vy_y + Vy_z * Vy_z); localToWorld[1, 0] = (float)(Vy_x * inverse_length); localToWorld[1, 1] = (float)(Vy_y * inverse_length); localToWorld[1, 2] = (float)(Vy_z * inverse_length); // Vz = (X,Y,Z) localToWorld[2, 0] = (float)X; localToWorld[2, 1] = (float)Y; localToWorld[2, 2] = (float)Z; return localToWorld; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); /** * 使用地图sdk前需先初始化BMapManager. * BMapManager是全局的,可为多个MapView共用,它需要地图模块创建前创建, * 并在地图地图模块销毁后销毁,只要还有地图模块在使用,BMapManager就不应该销毁 */ DemoApplication app = (DemoApplication)this.Application; if (app.mBMapManager == null) { app.mBMapManager = new BMapManager(ApplicationContext); /** * 如果BMapManager没有初始化则初始化BMapManager */ app.mBMapManager.Init(new DemoApplication.MyGeneralListener()); } /** * 由于MapView在setContentView()中初始化,所以它需要在BMapManager初始化之后 */ SetContentView(Resource.Layout.activity_layers); mMapView = FindViewById<MapView>(Resource.Id.bmapView); /** * 获取地图控制器 */ mMapController = mMapView.Controller; /** * 设置地图是否响应点击事件 . */ mMapController.EnableClick(true); /** * 设置地图缩放级别 */ mMapController.SetZoom(12); /** * 显示内置缩放控件 */ mMapView.SetBuiltInZoomControls(true); /** * 将地图移动至天安门 * 使用百度经纬度坐标,可以通过http://api.map.baidu.com/lbsapi/getpoint/index.html查询地理坐标 * 如果需要在百度地图上显示使用其他坐标系统的位置,请发邮件至[email protected]申请坐标转换接口 */ double cLat = 39.945; double cLon = 116.404; GeoPoint p = new GeoPoint((int)(cLat * 1E6), (int)(cLon * 1E6)); mMapController.SetCenter(p); }
internal static GeoPoint DecodeGeoHash(String value) { StringBuilder lBuffer = new StringBuilder(); foreach (Char c in value) { if (!_LookupTable.ContainsKey(c)) { throw new ArgumentException("Invalid character " + c); } Int32 i = _LookupTable[c] + 32; lBuffer.Append(Convert.ToString(i,2).Substring(1)); } BitArray lonset = new BitArray(_NumberOfBits); BitArray latset = new BitArray(_NumberOfBits); //even bits int j = 0; for (int i = 0; i < _NumberOfBits * 2; i += 2) { Boolean isSet = false; if (i < lBuffer.Length) { isSet = lBuffer[i] == '1'; } lonset[j] = isSet; j++; } //odd bits j = 0; for (int i = 1; i < _NumberOfBits * 2; i += 2) { Boolean isSet = false; if (i < lBuffer.Length) { isSet = lBuffer[i] == '1'; } latset[j] = isSet; j++; } double lLongitude = GeoHashDecode(lonset, -180, 180); double lLatitude = GeoHashDecode(latset, -90, 90); GeoPoint lResult = new GeoPoint(lLatitude,lLongitude); return lResult; }
internal static String EncodeGeoHash(GeoPoint data, Int32 accuracy) { BitArray latitudeBits = GeoHashEncode(data.Latitude, -90, 90); BitArray longitudeBits = GeoHashEncode(data.Longitude, -180, 180); StringBuilder buffer = new StringBuilder(); for (Int32 i = 0; i < _NumberOfBits; i++) { buffer.Append((longitudeBits[i]) ? '1' : '0'); buffer.Append((latitudeBits[i]) ? '1' : '0'); } String binaryValue = buffer.ToString(); String result = EncodeBase32(binaryValue); result = result.Substring(0, accuracy); return result; }
/** * Constructs a new extent. * * @param sw Southwest corner * @param ne Northeast corner * @param srs Spatial reference system */ public GeoExtent(GeoPoint _sw, GeoPoint _ne, SpatialReference _sr) { is_valid = false; is_infinite = false; if (_sw != null && _sw.getSRS() != null && _ne != null && _ne.getSRS() != null && _sr != null) { sw = _sr.transform(_sw); ne = _sr.transform(_ne); if (sw.isValid() && ne.isValid()) { is_valid = true; recalc(); } } }
/** * Constructs a new extent. * * @param sw Southwest corner * @param ne Northeast corner */ public GeoExtent(GeoPoint _sw, GeoPoint _ne) { is_valid = false; is_infinite = false; if (_sw != null && _sw.getSRS() != null && _ne != null && _ne.getSRS() != null) { sw = _sw; ne = _sw.getSRS().transform(_ne); if (ne.isValid()) { is_valid = true; recalc(); } } }
public IRoute GetRoute(RouteDestination destination, GeoPoint currentlocation) { return(GetArrivalRoute(currentlocation)); }
/// <summary> /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/> /// </summary> public override void OnSetAction() { base.TitleId = "CopyMatrixObjects"; BoundingRect result = originals.GetExtent(Frame.ActiveView.ProjectedModel.Projection, true, false); centerPoint = base.ActiveDrawingPlane.ToGlobal(result.GetCenter()); distX = result.Width; distY = result.Height; // da oben static private, werden diese Variablen gemerkt. Beim ersten Mal vorbesetzen: if ((horRight == 0) & (horLeft == 0) & (verUp == 0) & (verDown == 0)) { horRight = 3; verUp = 2; } // da oben static private, wird diese Variable gemerkt. Beim ersten Mal vorbesetzen: if (dirV.IsNullVector()) { dirV = new GeoVector(1.0, 0.0, 0.0); } IntInput horCountRight = new IntInput("CopyMatrixObjects.HorCountRight", horRight); horCountRight.SetMinMax(0, int.MaxValue, true); horCountRight.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountRight); // horCountRight.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountRight); IntInput verCountUp = new IntInput("CopyMatrixObjects.VerCountUp", verUp); verCountUp.SetMinMax(0, int.MaxValue, true); verCountUp.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountUp); // verCountUp.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountUp); horDist = new LengthInput("CopyMatrixObjects.HorDist", distX); horDist.SetDistanceFromLine(centerPoint, centerPoint + (dirV ^ base.ActiveDrawingPlane.Normal)); horDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetHorDist); verDist = new LengthInput("CopyMatrixObjects.VerDist", distY); verDist.SetDistanceFromLine(centerPoint, centerPoint + dirV); verDist.SetLengthEvent += new CADability.Actions.ConstructAction.LengthInput.SetLengthDelegate(SetVerDist); GeoVectorInput dir = new GeoVectorInput("CopyMatrixObjects.Direction", dirV); dir.Optional = true; dir.SetVectorFromPoint(centerPoint); dir.SetGeoVectorEvent += new CADability.Actions.ConstructAction.GeoVectorInput.SetGeoVectorDelegate(SetDir); dir.IsAngle = true; IntInput horCountLeft = new IntInput("CopyMatrixObjects.HorCountLeft", horLeft); horCountLeft.SetMinMax(0, int.MaxValue, true); horCountLeft.Optional = true; horCountLeft.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetHorCountLeft); // horCountLeft.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcHorCountLeft); IntInput verCountDown = new IntInput("CopyMatrixObjects.VerCountDown", verDown); verCountDown.SetMinMax(0, int.MaxValue, true); verCountDown.Optional = true; verCountDown.SetIntEvent += new CADability.Actions.ConstructAction.IntInput.SetIntDelegate(SetVerCountDown); // verCountDown.CalculateIntEvent +=new CADability.Actions.ConstructAction.IntInput.CalculateIntDelegate(CalcVerCountDown); base.SetInput(horCountRight, verCountUp, horDist, verDist, dir, horCountLeft, verCountDown); base.OnSetAction(); showMatrix(); }
private bool WithinRanage(GeoPoint searchElement, GeoPoint listElement, float range) { var d = searchElement.Distance(listElement.ToVector2()); return(d <= range); }
public override void OnSetAction() { base.ActiveObject = block; base.TitleId = "ScaleObjects"; dis = ConstrDefaults.DefaultScaleDistort; copyObject = ConstrDefaults.DefaultCopyObjects; feedBackLine = Line.Construct(); Color backColor = base.Frame.GetColorSetting("Colors.Feedback", Color.DarkGray); feedBackLine.ColorDef = new ColorDef("", backColor); base.SetCursor(SnapPointFinder.DidSnapModes.DidNotSnap, "Size"); clickandPress = false; GeoPointInput fixPoint = new GeoPointInput("Objects.FixPoint", base.BasePoint); fixPoint.Optional = true; fixPoint.DefinesHotSpot = true; fixPoint.HotSpotSource = "Hotspots.png:0"; fixPoint.SetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.SetGeoPointDelegate(SetfixPoint); fixPoint.GetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.GetGeoPointDelegate(GetfixPoint); // dieser Punkt mit dem Fixpunkt dient zur Faktor-Bestimmung, "1" läßt ihn unverändert, "2" verdoppelt seine Entfernung vom Fixpunkt startPointInput = new GeoPointInput("Objects.StartPoint"); startPointInput.Optional = true; startPointInput.SetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.SetGeoPointDelegate(SetStartPoint); startPointInput.GetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.GetGeoPointDelegate(GetStartPoint); endPointInput = new GeoPointInput("Objects.EndPoint"); endPointInput.Optional = true; endPointInput.SetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.SetGeoPointDelegate(SetEndPoint); endPointInput.GetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.GetGeoPointDelegate(GetEndPoint); fac = new DoubleInput("ScaleObjects.Factor", faktor); fac.ReadOnly = dis; fac.Optional = dis; fac.SetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.SetDoubleDelegate(SetFactor); fac.GetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.GetDoubleDelegate(GetFactor); fac.CalculateDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.CalculateDoubleDelegate(CalculateFactor); fac.MouseClickEvent += new MouseClickDelegate(facOnMouseClick); // Verzerrung BooleanInput distort = new BooleanInput("ScaleObjects.Distort", "ScaleObjects.Distort.Values"); distort.DefaultBoolean = ConstrDefaults.DefaultScaleDistort; distort.SetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.SetBooleanDelegate(SetDistort); fac1 = new DoubleInput("ScaleObjects.FactorX"); fac1.ReadOnly = !dis; fac1.Optional = !dis; fac1.SetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.SetDoubleDelegate(SetFactor1); fac1.GetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.GetDoubleDelegate(GetFactor1); fac1.CalculateDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.CalculateDoubleDelegate(CalculateFactor); fac1.MouseClickEvent += new MouseClickDelegate(facOnMouseClick); fac2 = new DoubleInput("ScaleObjects.FactorY"); fac2.ReadOnly = !dis; fac2.Optional = !dis; // fac2.Optional = true; fac2.SetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.SetDoubleDelegate(SetFactor2); fac2.GetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.GetDoubleDelegate(GetFactor2); fac2.CalculateDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.CalculateDoubleDelegate(CalculateFactor2); fac3 = new DoubleInput("ScaleObjects.FactorZ"); fac3.ReadOnly = !dis; fac3.Optional = !dis; // fac2.Optional = true; fac3.SetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.SetDoubleDelegate(SetFactor3); fac3.GetDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.GetDoubleDelegate(GetFactor3); fac3.CalculateDoubleEvent += new CADability.Actions.ConstructAction.DoubleInput.CalculateDoubleDelegate(CalculateFactor3); BooleanInput copy = new BooleanInput("Modify.CopyObjects", "YesNo.Values"); copy.DefaultBoolean = ConstrDefaults.DefaultCopyObjects; copy.SetBooleanEvent += new CADability.Actions.ConstructAction.BooleanInput.SetBooleanDelegate(SetCopy); // erstmal wird das umgebende Rechteck bestimmt cube = BoundingCube.EmptyBoundingCube; foreach (IGeoObject go in originals) { cube.MinMax(go.GetBoundingCube()); } GeoPoint blockCenter = cube.GetCenter(); block.RefPoint = blockCenter; // im Basepoint steht der Fixpunkt der Skalierung base.BasePoint = blockCenter; base.SetInput(fixPoint, fac, startPointInput, endPointInput, distort, fac1, fac2, fac3, copy); base.OnSetAction(); }
private double CalcFactor(GeoPoint MousePosition) { startPoint = MousePosition; return(faktor); }
private void CenterMap(GeoPoint location) { this.MapCenter = location; }
private void UpdateWindowTitle() { GeoPoint g = mapControl.Mouse; this.Text = $"Mouse = {g} / Zoom = {mapControl.ZoomLevel} "; }
private void CirclePoint2(GeoPoint p) { circlePoint2 = p; showCircle(circlePoint2); }
private void CirclePoint3(GeoPoint p) { circlePoint3 = p; showCircle(circlePoint3); }
private void CirclePoint1(GeoPoint p) { circlePoint1 = p; showCircle(circlePoint1); }
private void StartPoint(GeoPoint p) { // line.RectangleLocation = p; line.SetRectangle(p, line.RectangleWidth * base.ActiveDrawingPlane.DirectionX, line.RectangleHeight * base.ActiveDrawingPlane.DirectionY); }
public async Task <GeoObjectCollection> ReverseGeocodeAsync(GeoPoint point, GeoObjectKind kind) { return(await this.ReverseGeocodeAsync(point, GeoObjectKind.House, 10000)); }
private IRoute GetArrivalRoute(GeoPoint currentlocation) { return(_weatherController.WindDegrees < 180 ? GetArrivalRoute09(currentlocation) : GetArrivalRoute27(currentlocation)); }
public SearchLocation(PredictionResult predictionResult, GeoPoint coordinates, [Range(0, 40000)] int distanceInMeters) { Coordinates = coordinates; DistanceInMeters = distanceInMeters; PredictionResult = predictionResult; }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger logger, CancellationToken token) { return(await req.Wrap <ReindeerRescueRequest>(logger, async request => { if (request == null) { return new BadRequestErrorMessageResult("Request is empty."); } if (string.IsNullOrWhiteSpace(request.Id)) { return new BadRequestErrorMessageResult($"Missing required value for property '{nameof(ReindeerRescueRequest.Id)}'."); } if (!Guid.TryParse(request.Id, out Guid id)) { return new BadRequestErrorMessageResult($"Value for property '{nameof(ReindeerRescueRequest.Id)}' is not a valid ID or has an invalid format (example of valid value and format for Unique Identifier (GUID): '135996C9-3090-4399-85DB-1F5041DF1DDD')."); } Attempt attempt = await _attemptService.Get(id, 2, token); if (attempt == null) { return new NotFoundResult(); } if (!attempt.SantaRescueAt.HasValue) { return new BadRequestErrorMessageResult($"It looks like you're reusing an old ID from a previous failed attempt created {attempt.Created} - you need to start all over again - remember not to hard code any IDs in your application."); } if (attempt.ReindeerInZones == null) { throw new InvalidOperationException($"Missing value for '{nameof(attempt.ReindeerInZones)}' on attempt with Id '{attempt.Id}'."); } var messages = new List <string>(); if (request.Locations == null) { messages.Add($"Missing required value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}'."); } else if (request.Locations.Length > attempt.ReindeerInZones.Length) { messages.Add($"Invalid value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}'. Expected a maximum number of locations to be {attempt.ReindeerInZones.Length} - but was {request.Locations.Length}."); } else { for (int i = 0; i < attempt.ReindeerInZones.Length; i++) { ReindeerInZone zone = attempt.ReindeerInZones[i]; ReindeerRescueRequest.ReindeerLocation locationInRequest = request.Locations?.ElementAtOrDefault(i); if (locationInRequest == null) { messages.Add($"Missing required value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}]'."); } else if (string.IsNullOrWhiteSpace(locationInRequest.Name)) { messages.Add($"Missing required value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}].{nameof(ReindeerRescueRequest.ReindeerLocation.Name).WithFirstCharToLowercase()}'"); } else if (locationInRequest.Name.Length >= 100) { messages.Add($"Invalid value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}].{nameof(ReindeerRescueRequest.ReindeerLocation.Name).WithFirstCharToLowercase()}' - length exceeds maximum of 100 characters."); } else if (!string.Equals(locationInRequest.Name, zone.Reindeer.ToString())) { messages.Add($"Expected name of Reindeer for '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}].{nameof(ReindeerRescueRequest.ReindeerLocation.Name).WithFirstCharToLowercase()}' to be '{zone.Reindeer}' - but was '{locationInRequest.Name}'."); } else if (locationInRequest.Position == null) { messages.Add($"Missing required value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}].{nameof(ReindeerRescueRequest.ReindeerLocation.Position).WithFirstCharToLowercase()}'"); } else { Point center = new Point(zone.Center.Lon, zone.Center.Lat); double radiusInMeter = zone.Radius.InMeter(); string name = zone.Reindeer.ToString(); var feedOptions = new FeedOptions { PartitionKey = new PartitionKey(zone.CountryCode), MaxItemCount = 1 }; ObjectInLocationForCosmosDb actualReindeer = _documentClient .CreateDocumentQuery <ObjectInLocationForCosmosDb>(UriFactory.CreateDocumentCollectionUri("World", "Objects"), feedOptions) .Where(u => u.Name == name && center.Distance(u.Location) <= radiusInMeter) .AsEnumerable() .FirstOrDefault(); if (actualReindeer == null) { throw new InvalidOperationException($"Reindeer '{name}' not found for zone {zone.Center}, Country {zone.CountryCode}."); } GeoPoint actualPosition = actualReindeer.GetLocation(); if (!actualPosition.Equals(locationInRequest.Position)) { messages.Add($"Invalid value for property '{nameof(ReindeerRescueRequest.Locations).WithFirstCharToLowercase()}[{i}].{nameof(ReindeerRescueRequest.ReindeerLocation.Position).WithFirstCharToLowercase()}'. Reindeer '{zone.Reindeer}' was not found at {locationInRequest.Position} - actual position is {actualPosition}."); } } } } if (messages.Count > 0) { attempt.InvalidReindeerRescue = messages.ToArray(); await _attemptService.Save(attempt, 3, token); return new BadRequestErrorMessageResult($@"Unfortunately one or more reindeer was not at the specified locations. Below is the detailed rescue report from the extraction team: {string.Join(Environment.NewLine, messages.Select(x => $"\t - {x}"))} Please try again - and remember since the reindeer has probably moved their locations by now, you'll have to start all over again."); } attempt.ReindeersRescueAt = DateTimeOffset.UtcNow; Uri problemUri = await _toyDistributionProblemRepository.Save(attempt, ToyDistributionProblem.Create(), token); await _attemptService.Save(attempt, 3, token); return new OkObjectResult(new ReindeerRescueResponse(problemUri)); })); }
public SantaInformation() { CanePosition = new GeoPoint(0, 0); SantaMovements = new List <SantaMovement>(); }
public void Store(GeoPoint geoPoint, Double zoomLevel) { App.Settings.MapLatitude = geoPoint.Latitude; App.Settings.MapLongitude = geoPoint.Longitude; App.Settings.MapZoomLevel = zoomLevel; }
private double CalculateFactor3(GeoPoint MousePosition) { return(faktorZ); // return facH; }
private double CalculateFactor(GeoPoint MousePosition) { if (!startPointInput.Fixed) { startPoint = MousePosition; } double divRBx; // Abstand rect-Rand zu Referenzpunt in x-Richtung double divRBy; // Abstand rect-Rand zu Referenzpunt in y-Richtung double divRBz; // Abstand rect-Rand zu Referenzpunt in z-Richtung double divMBx; // Abstand MousePosition zu Referenzpunt in x-Richtung double divMBy; // Abstand MousePosition zu Referenzpunt in y-Richtung double divMBz; // Abstand MousePosition zu Referenzpunt in z-Richtung BoundingCube cubeLoc = cube; // der umgebende Kubus der Objekte cubeLoc.MinMax(base.BasePoint); // der Punkt kommt noch mit dazu, kann ja auch ausserhalb liegen // es wird ein Faktor gebildet aus: (Abstand rect-Rand und Referenzpunkt) und (Abstand MousePos. und Referenzpunkt), // getrennt für alle vier Quadranten if (MousePosition.x > base.BasePoint.x) { divRBx = cubeLoc.Xmax - base.BasePoint.x; divMBx = MousePosition.x - base.BasePoint.x; } else { divRBx = base.BasePoint.x - cubeLoc.Xmin; divMBx = base.BasePoint.x - MousePosition.x; } if (MousePosition.y > base.BasePoint.y) { divRBy = cubeLoc.Ymax - base.BasePoint.y; divMBy = MousePosition.y - base.BasePoint.y; } else { divRBy = base.BasePoint.y - cubeLoc.Ymin; divMBy = base.BasePoint.y - MousePosition.y; } if (MousePosition.z > base.BasePoint.z) { divRBz = cubeLoc.Zmax - base.BasePoint.z; divMBz = MousePosition.z - base.BasePoint.z; } else { divRBz = base.BasePoint.z - cubeLoc.Zmin; divMBz = base.BasePoint.z - MousePosition.z; } // jetzt werden die drei Faktoren bestimmt if (Math.Abs(divRBx) <= 1e-6) { faktorX = 0; } else { faktorX = divMBx / divRBx; } if (Math.Abs(divRBy) <= 1e-6) { faktorY = 0; } else { faktorY = divMBy / divRBy; } if (Math.Abs(divRBz) <= 1e-6) { faktorZ = 0; } else { faktorZ = divMBz / divRBz; } // falls einer ausfällt: den größten anderen nehmen, das erhöht den Benutzungskomfort if (faktorX == 0) { faktorX = Math.Max(faktorY, faktorZ); } if (faktorY == 0) { faktorY = Math.Max(faktorX, faktorZ); } if (faktorZ == 0) { faktorZ = Math.Max(faktorX, faktorY); } if (dis) { return(faktorX); // falls Verzerrung: nur x-Wert, also: facWidth, facH ist global und wird in Setfaktor verwurstet } // if (divMBx == 0) return Math.Max(faktorY,faktorZ); // if (divRBx == 0) return ; // die Auswahl, welcher von beiden benutzt wird, Quadranten als Strahlen vom Referenzpunkt dirch die Ecken des umgebenden Rechtecks rectLoc if ((divMBy / divMBx) > (divRBy / divRBx)) { if ((divMBy / divMBz) > (divRBy / divRBz)) { return(faktorZ); } else { return(faktorY); } } else { if ((divMBx / divMBz) > (divRBx / divRBz)) { return(faktorZ); } else { return(faktorX); } } //BoundingRect rectLoc = rect; //rectLoc.MinMax(base.ActiveDrawingPlane.Project(base.BasePoint)); // der Punkt kann ja auch ausserhalb liegen //// es wird ein Faktor gebildet aus: (Abstand rect-Rand und Referenzpunkt) und (Abstand MousePos. und Referenzpunkt), //// getrennt für alle vier Quadranten //if (MousePosition.x > base.BasePoint.x) //{ // divRBx = rectLoc.Right - base.BasePoint.x; // divMBx = MousePosition.x - base.BasePoint.x; //} //else //{ // divRBx = base.BasePoint.x - rectLoc.Left; // divMBx = base.BasePoint.x - MousePosition.x; //} //if (MousePosition.y > base.BasePoint.y) //{ // divRBy = rectLoc.Top - base.BasePoint.y; // divMBy = MousePosition.y - base.BasePoint.y; //} //else //{ // divRBy = base.BasePoint.y - rectLoc.Bottom; // divMBy = base.BasePoint.y - MousePosition.y; //} //// jetzt werden die beiden Faktoren bestimmt //if (divRBy == 0) facH = 0; //else facH = divMBy / divRBy; //if (divRBx == 0) facW = 0; //else facW = divMBx / divRBx; //if (dis) return facW; // falls Verzerrung: nur x-Wert, also: facWidth, facH ist global und wird in Setfaktor verwurstet //// falls einer ausfällt: den anderen nehmen, das erhöht den Benutzungskomfort //if (facH == 0) facH = facW; //if (facW == 0) facW = facH; //if (divMBx == 0) return facH; //if (divRBx == 0) return facW; //// die Auswahl, welcher von beiden benutzt wird, Quadranten als Strahlen vom Referenzpunkt dirch die Ecken des umgebenden Rechtecks rectLoc //if ((divMBy / divMBx) > (divRBy / divRBx)) // return facH; //else return facW; }
private void OnFilterSinglePointCommand(GeoPointProperty sender, string menuId, CommandState commandState, ref bool handled) { int index = (int)sender.UserData["Index"]; if (commandState != null) { // es wird nur nach der Menuedarstellung gefragt switch (menuId) { case "MenuId.IndexedPoint.InsertAfter": if (index == controlledObject.GetGeoPointCount() - 1) { index = -1; } else { index += 1; } commandState.Enabled = controlledObject.MayInsert(index); handled = true; break; case "MenuId.IndexedPoint.InsertBefore": commandState.Enabled = controlledObject.MayInsert(index); handled = true; break; case "MenuId.IndexedPoint.Delete": commandState.Enabled = controlledObject.MayDelete(index); handled = true; break; } } else { try { GeoPoint p = controlledObject.GetGeoPoint(index); switch (menuId) { case "MenuId.IndexedPoint.InsertAfter": if (index == controlledObject.GetGeoPointCount() - 1) { index = -1; } else { index += 1; } if (GetInsertionPointEvent != null) { p = GetInsertionPointEvent(this, index, true); } else if (index > 0) { p = new GeoPoint(controlledObject.GetGeoPoint(index - 1), controlledObject.GetGeoPoint(index)); } controlledObject.InsertGeoPoint(index, p); handled = true; break; case "MenuId.IndexedPoint.InsertBefore": if (GetInsertionPointEvent != null) { p = GetInsertionPointEvent(this, index, false); } else if (index > 0) { p = new GeoPoint(controlledObject.GetGeoPoint(index - 1), controlledObject.GetGeoPoint(index)); } controlledObject.InsertGeoPoint(index, p); handled = true; break; case "MenuId.IndexedPoint.Delete": controlledObject.RemoveGeoPoint(index); handled = true; break; case "MenuId.Point.NameVariable": if (Frame != null) { Frame.Project.SetNamedValue(null, p); handled = true; } break; } } catch (IndexOutOfRangeException e) { } } }
public static void StoreGeoPointInDB(GeoPoint geoPoint) { Data.CSBooster_DataAccessDataContext csbDAC = new _4screen.CSB.DataAccess.Data.CSBooster_DataAccessDataContext(); csbDAC.hisp_GeoKoordinates_Save(geoPoint.StreetAndNumber, geoPoint.ZipCode, geoPoint.City, geoPoint.CountryCode, geoPoint.Region, geoPoint.Lat, geoPoint.Long); }
public GeneralAngleAction(AngleProperty angleProperty, GeoPoint fixPoint) { this.angleProperty = angleProperty; this.fixPoint = fixPoint; usesLocalPlane = false; }
private void SetfixPoint(GeoPoint p) { block.RefPoint = p; base.BasePoint = p; // der Fixpunkt }
public Location(GeoPoint coordinates, int distance, LocationTypes type = LocationTypes.Unknown) : this(string.Empty, string.Empty, string.Empty, coordinates, distance, PredictionSources.NotSpecified, type, null) { }
protected override bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found) { double mindist = double.MaxValue; found = GeoPoint.Origin; // nur beim dritten Punkt: if (CurrentInput == arcPoint3Input && arcPoint1Input.Fixed && arcPoint2Input.Fixed) { GeoObjectList l = base.GetObjectsUnderCursor(e.Location); l.DecomposeAll(); GeoPoint inpoint = base.WorldPoint(e.Location); Plane pln = Plane.XYPlane; bool plnOK = false; for (int i = 0; i < l.Count; i++) { if (l[i] is ICurve) { ICurve curve = l[i] as ICurve; if (curve is Line) { double eps; bool linear; // alles in einer Ebene? In welcher? pln = Plane.FromPoints(new GeoPoint[] { circlePoint1, circlePoint2, (curve as Line).StartPoint, (curve as Line).EndPoint }, out eps, out linear); plnOK = !(linear || eps > Precision.eps); } if (curve is Ellipse) { pln = (curve as Ellipse).GetPlane(); // alles in einer Ebene? plnOK = !((pln.Distance(circlePoint1) > Precision.eps) || (pln.Distance(circlePoint2) > Precision.eps)); } if (plnOK) { // Hilfskreise machen um die ersten 2 Punkte: Ellipse circLoc1; circLoc1 = Ellipse.Construct(); circLoc1.SetCirclePlaneCenterRadius(pln, circlePoint1, 0.0); Ellipse circLoc2; circLoc2 = Ellipse.Construct(); circLoc2.SetCirclePlaneCenterRadius(pln, circlePoint2, 0.0); // Achtung! Die Sortierung mit Linie(n) am Anfang ist wichtig für die Auswertung des Abstandes!! ICurve2D l2D1 = (l[i] as ICurve).GetProjectedCurve(pln); ICurve2D l2D2 = circLoc1.GetProjectedCurve(pln); ICurve2D l2D3 = circLoc2.GetProjectedCurve(pln); GeoPoint2D[] tangentPoints = Curves2D.TangentCircle(l2D1, l2D2, l2D3, pln.Project(inpoint), pln.Project(circlePoint1), pln.Project(circlePoint2)); if (tangentPoints.Length > 0) { for (int k = 0; k < tangentPoints.Length; k += 4) { double dist = Geometry.Dist(tangentPoints[k + 1], pln.Project(inpoint)); if (dist < mindist) { mindist = dist; found = pln.ToGlobal(tangentPoints[k + 1]); } } } } } } } return(mindist != double.MaxValue); }
public async Task <GeoObjectCollection> ReverseGeocodeAsync(GeoPoint point, GeoObjectKind kind, short results) { return(await this.ReverseGeocodeAsync(point, GeoObjectKind.House, 10000, LangType.RU)); }
private void OnSetGeoPoint(GeoPointProperty sender, GeoPoint p) { int index = (int)sender.UserData["Index"]; controlledObject.SetGeoPoint(index, p); }
private void RaisePositionValueUpdatedEvent(GeoPoint position) { this.PositionValueUpdated?.Invoke(this, new AnimationValueUpdatedEventArgs(position)); }
public MultirotorState(CollisionInfo collision, KinemticState kinemtic_estimate, KinemticState kinematic_true, GeoPoint point, long time) { this.collision = collision; this.kinematics_estimated = kinemtic_estimate; this.kinematics_true = kinematic_true; this.gps_location = point; this.timestamp = time; }
public async Task AddingGettingAndDeletingInputsShouldBeSuccessful() { string inputID1 = GenerateRandomID(); string inputID2 = GenerateRandomID(); try { var geoPoint = new GeoPoint(55, 66); /* * Add new inputs. */ ClarifaiResponse <List <IClarifaiInput> > addResponse = await Client.AddInputs( new ClarifaiURLImage( CELEB1, id : inputID1, allowDuplicateUrl : true, geo : geoPoint), new ClarifaiURLImage(APPAREL1, id : inputID2, allowDuplicateUrl : true)) .ExecuteAsync(); Assert.True(addResponse.IsSuccessful); /* * Get inputs' status. */ ClarifaiResponse <ClarifaiInputsStatus> getInputsStatusResponse = await Client.GetInputsStatus().ExecuteAsync(); Assert.AreEqual(ClarifaiStatus.StatusType.Successful, getInputsStatusResponse.Status.Type); /* * Get the inputs. */ ClarifaiResponse <List <IClarifaiInput> > getResponse = await Client.GetInputs() .ExecuteAsync(); Assert.True(getResponse.IsSuccessful); /* * Get input 1. */ ClarifaiResponse <IClarifaiInput> getInput1Response = await Client.GetInput(inputID1) .ExecuteAsync(); Assert.True(getInput1Response.IsSuccessful); Assert.AreEqual(geoPoint, getInput1Response.Get().Geo); Assert.NotNull(getInput1Response.Get().CreatedAt); /* * Get input 2. */ ClarifaiResponse <IClarifaiInput> getInput2Response = await Client.GetInput(inputID1) .ExecuteAsync(); Assert.True(getInput2Response.IsSuccessful); } finally { /* * Delete the inputs. */ var deleteResponse = await Client.DeleteInputs(inputID1, inputID2) .ExecuteAsync(); Assert.True(deleteResponse.IsSuccessful); } }