private void AddMapName(TextPosInfo textPosInfo) { //check if there's collide foreach (var o in _textInfos) { foreach (var p in textPosInfo._rectangles) { foreach (var q in o._rectangles) { if (p.IntersectsWith(q)) { return; } } } } bool somethingInScreen = true; foreach (var p in textPosInfo._rectangles) { GeoBounds geoBounds = new GeoBounds(p.X, p.Y, p.Width, p.Height); if (!_mapSize.Contains(geoBounds)) { somethingInScreen = false; break; } } if (somethingInScreen) { _textInfos.Add(textPosInfo); } }
private void DrawRegion(MapPen mapPen, MapBrush mapBrush, GeoPolygon region) { Pen pen = new Pen(Color.FromArgb((int)(mapPen.Color | 0xFF000000)), mapPen.Width); Brush brush = GetBrush(mapBrush); GeoBounds bounds = new GeoBounds(118.808451, 31.907395, 0.003907, 0.0035); ArrayList clippedPts = _sutherlandHodgman.ClipRegion(region.GetPoints()); GeoPoint[] screenPts = FromLatLngToMapPixel(clippedPts); if (screenPts.Length > 2) { { int[] xpoints = new int[screenPts.Length]; int[] ypoints = new int[screenPts.Length]; for (int i = 0; i < screenPts.Length; i++) { xpoints[i] = (int)screenPts[i].X; ypoints[i] = (int)screenPts[i].Y; } Point[] points = new Point[xpoints.Length]; for (int i = 0; i < points.Length; i++) { points[i] = new Point(xpoints[i], ypoints[i]); } SharedGraphics2D.Graphics.DrawPolygon(pen, points); SharedGraphics2D.Graphics.FillPolygon(brush, points); } } }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 21JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Open the map. * @ */ public void Open() { lock (_mapFeatureLayers) { int layerCount = _mapFeatureLayers.Count; if (layerCount > 0) { ((MapFeatureLayer)_mapFeatureLayers[0]).Open(); _bounds = ((MapFeatureLayer)_mapFeatureLayers[0]).Bounds; } else { _bounds = new GeoLatLngBounds(); } for (int i = 1; i < layerCount; i++) { MapFeatureLayer mapLayer = (MapFeatureLayer)_mapFeatureLayers[i]; mapLayer.Open(); GeoBounds.Union(mapLayer.Bounds, _bounds, _bounds); } } }
public CountryInfo(Continent continent, string administrativeName, IGeometry geomentryData, Uri smallFlag, Uri largeFlag, bool longitudeWrap, int zIndex, double toleranceLow, double toleranceHi) { Continent = continent; AdministrativeName = administrativeName; if (geomentryData is Polygon) { var delta = ((Polygon)geomentryData).GetArea().Value; GeomentryData = new List <GeoPolygon> { ConvertPolygon((Polygon)geomentryData, false, longitudeWrap) }; } else if (geomentryData is MultiPolygon) { var polygons = ((MultiPolygon)geomentryData).Geometries .Cast <Polygon>() .Where(p => p.GetArea().Value > 0) .Select(p => new { Polygon = p, Area = p.GetArea().Value, Bounds = p.GetBounds() }) .ToList(); var countryBounds = geomentryData.GetBounds(); var area = polygons.MaxBy(a => a.Area); var dist = Math.Sqrt( Math.Pow(countryBounds.MaxLon - countryBounds.MinLon - area.Bounds.MaxLon + area.Bounds.MinLon, 2) + Math.Pow(countryBounds.MaxLat - countryBounds.MinLat - area.Bounds.MaxLat + area.Bounds.MinLat, 2) ); var total = polygons.Sum(a => a.Area); GeomentryData = polygons .Select(p => ConvertPolygon(p.Polygon, p.Area / total < (toleranceLow + toleranceHi * GetDistance(area.Bounds, p.Bounds) / dist), longitudeWrap)) .ToList(); } else { GeomentryData = new List <GeoPolygon>(); } var bounds = GeomentryData.Where(p => !p.Ignored); Bounds = new GeoBounds( bounds.Min(p => p.Bounds.Left), bounds.Min(p => p.Bounds.Top), bounds.Max(p => p.Bounds.Right), bounds.Max(p => p.Bounds.Bottom)); SmallFlag = smallFlag; LargeFlag = largeFlag; Borders = new List <IBorderInfo>(); ZIndex = zIndex; IsSmall = GeomentryData.Max(g => g.Area) < SmallCountryAreaThreshold; }
public CountryAreaFill(Uri flag, GeoBounds areaBounds, GeoBounds countryBounds, bool markerOnly) { Flag = flag; X = areaBounds.Left - countryBounds.Left; Y = areaBounds.Top - countryBounds.Top; Width = areaBounds.Right - areaBounds.Left; Height = areaBounds.Bottom - areaBounds.Top; CountryWidth = countryBounds.Right - countryBounds.Left; CountryHeight = countryBounds.Bottom - countryBounds.Top; MarkerOnly = markerOnly; }
public MapAreaMV(SelectionMarker selectionMarker, ICountryQuestion question, GeoBounds bounds, bool markerOnly) { _selectionMarker = selectionMarker; _question = question; _question.OnStateChanged += (s, e) => FillState = e.State; _selectionMarker.OnSelectedChanged += (s, e) => Selected = e; StartGuessCommand = new RelayCommand(() => { if (_question.State == QuestionState.Unanswered && !_selectionMarker.Selected) { MessengerInstance.Send(new StartCountryGuessNotification(_question, _selectionMarker)); } }); Fill = new CountryAreaFill(question.Country.LargeFlag, bounds, question.Country.Bounds, markerOnly); ZIndex = question.Country.ZIndex; Visible = true; }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 20JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Open the map. * @throws IOException if there's problem opening the map. */ public void Open() { lock (_mapTiledZones) { int layerCount = _mapTiledZones.Count; if (layerCount > 0) { ((MapTiledZone)_mapTiledZones[0]).Open(); _bounds = ((MapTiledZone)_mapTiledZones[0]).Bounds; } else { _bounds = new GeoLatLngBounds(); } for (int i = 1; i < layerCount; i++) { MapTiledZone mapTiledZone = (MapTiledZone)_mapTiledZones[i]; mapTiledZone.Open(); GeoBounds.Union(mapTiledZone.Bounds, _bounds, _bounds); } } }
public GeoBoundsAggregate() { Bounds = new GeoBounds(); }
public void SaveRoute(RawRoute route, IEnumerable<StopPoint> stops, GeoBounds bounds) { var coords = stops.Select(s => new GeoJson2DGeographicCoordinates(s.longitude, s.latitude)); var line = new GeoJsonLineString<GeoJson2DGeographicCoordinates>( new GeoJsonLineStringCoordinates<GeoJson2DGeographicCoordinates>(coords)); BsonDocument bsonRoute = new BsonDocument { {"RouteName", route.RouteName}, {"stops" , line.ToBsonDocument() }, {"maxLongitude",bounds.TopLeft.Longitude}, {"minLongitude",bounds.BottomRight.Longitude}, {"maxLatitude", bounds.BottomRight.Latitude}, {"minLatitude",bounds.TopLeft.Latitude} }; Routes.Save(bsonRoute); }
public GeoBoundsMetric() { Bounds = new GeoBounds(); }
float metricToValue(KSProject proj, KSMetric metric, string type) { string label = metric.Name; GeoBounds gb = GeoBounds.List[GA.Geographic]; if (label == "Latitude") { return((proj.GetMetric("Lat") - gb.Bottom) * 10 / gb.Scale); } if (label == "Longitude") { return((proj.GetMetric("Lon") - gb.Left) * 10 / gb.Scale); } float zoom = GA.zoom; float s, logValue; if (type == "linear") { return(proj.GetMetric(label) / metric.Zoom / zoom); } else { //s ^ 10 = modifier * zoom * 10 //s ^ x = value s = Mathf.Log(metric.Zoom * zoom, 10); logValue = proj.GetMetric(label) > 0 ? Mathf.Log(proj.GetMetric(label), s) : 0; //Debug.Log(s + " ^ " + logValue + " = " + proj.GetMetric(label)); return(logValue); } return(0); /* * switch(label.ToLower()) * //switch(label) * { * case "raised": * if(type == "linear") * return proj.raised / Modifiers["Raised"] / zoom; * else * { * // s ^ 10 = modifier * zoom * 10 * // s ^ x = value * s = Mathf.Log(Modifiers["Raised"] * zoom, 10); * logValue = proj.raised > 0 ? Mathf.Log(proj.raised, s) : 0; * * //Debug.Log(s + " ^ " + logValue + " = " + proj.raised); * return logValue; * } * break; * * case "goal": * //return proj.goal / Modifiers["Goal"] / zoom; * val = proj.goal / Modifiers["Goal"] / zoom; * if(type == "linear") * return val; * else * { * s = Mathf.Log(Modifiers["Goal"] * zoom, 10); * logValue = proj.goal > 0 ? Mathf.Log(proj.goal, s) : 0; * * //Debug.Log(proj.raised + " ^ " + s + " = " + logValue); * return logValue; * } * break; * * case "backers": * //return proj.backers / Modifiers["Backers"] / zoom; * if(type == "linear") * return proj.backers / Modifiers["Backers"] / zoom; * else * { * s = Mathf.Log(Modifiers["Backers"] * zoom, 10); * logValue = proj.backers > 0 ? Mathf.Log(proj.backers, s) : 0; * return logValue; * } * break; * case "comments": * //return proj.comments / Modifiers["Comments"] / zoom; * if(type == "linear") * return proj.comments / Modifiers["Comments"] / zoom; * else * { * s = Mathf.Log(Modifiers["Comments"] * zoom, 10); * logValue = proj.comments > 0 ? Mathf.Log(proj.comments, s) : 0; * return logValue; * } * break; * case "dpb": * //return proj.backers == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; * if(type == "linear") * return Mathf.Min(proj.backers, proj.raised) == 0 ? 0 : proj.raised / proj.backers / Modifiers["DpB"] / zoom; * else * { * s = Mathf.Log(Modifiers["DpB"] * zoom, 10); * logValue = proj.backers > 0 ? Mathf.Log(proj.raised / proj.backers, s) : 0; * return logValue; * } * break; * case "% raised": * //return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; * if(type == "linear") * return proj.raised / proj.goal / Modifiers["% Raised"] / zoom; * else * { * s = Mathf.Log(Modifiers["DpB"] * zoom, 10); * logValue = proj.raised > 0 ? Mathf.Log((proj.raised / proj.goal) + 1, s) : 0; * return logValue; * } * break; * case "latitude": * return (proj.lat - gb.Bottom) * 10 / gb.Scale; * break; * case "longitude": * return (proj.lon - gb.Left) * 10 / gb.Scale; * break; * case "zero": * default: * return 0; * break; * * }*/ }