public void DrawMarkers(IEnumerable<Land> landPieces) { if (landPieces == null) return; ClearGraphics(); if (Current.Instance.MapControl.Viewport.Resolution > 50) { return; } foreach (var land in landPieces.Where(x => x.DemandAuthorities)) { var sphericalMid = SphericalMercator.FromLonLat(land.Longitude, land.Latitude); var feature = new Feature { Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y), }; var offset = new Offset(); offset.X = 100; double scale = 19.109256744384766 / Current.Instance.MapControl.Viewport.Resolution; //var symbolStyle = new SymbolStyle { Symbol = GetSymbol("demandar.png"), SymbolType = SymbolType.Rectangle, SymbolOffset = offset, SymbolScale = scale }; var symbolStyle = new SymbolStyle { Symbol = GetSymbol("demandar.png"), SymbolScale = 1 }; feature.Styles.Add(symbolStyle); source.Features.Add(feature); } Current.Instance.MapControl.OnViewChanged(true); }
void layerRequest_LayerRecived(object sender, EventArgs e) { Polygon poligono; Earthwatchers.Models.KmlModels.Layer layer = sender as Earthwatchers.Models.KmlModels.Layer; if (layer != null) { isFirstTime = false; layersTest = layer; foreach (Earthwatchers.Models.KmlModels.Zone zon in layer.Zones) { foreach (var p in zon.Polygons) { poligono = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(p.Locations.Select(l => new Location(l.Longitude.Value, l.Latitude.Value)).ToList())) }; var feature = new Feature { Geometry = poligono }; var vStyle = new VectorStyle { Fill = new Brush { Color = Color.FromArgb(48, 255, 255, 255) }, Outline = new Pen { Color = Color.FromArgb(100, 241, 251, 187), Width = 2 }, //#F1FBBB }; feature.Styles.Add(vStyle); _source.Features.Add(feature); } } Current.Instance.MapControl.OnViewChanged(true); } Current.Instance.MapControl.OnViewChanged(true); }
public static ILayer Create() { var layer = new Layer("PointLayer"); var pointWithDefaultSymbolStyle = new Feature { Geometry = new Point(1000000, 1000000)}; pointWithDefaultSymbolStyle.Styles.Add(new SymbolStyle()); var pointAsSmallBlackDot = new Feature { Geometry = new Point(1000000, 0)}; pointAsSmallBlackDot.Styles.Add(new SymbolStyle { SymbolScale = 2.0f, Fill = new Brush { Color = null }, Outline = new Pen { Color = Color.Green} }); pointAsSmallBlackDot.Styles.Add(new SymbolStyle { SymbolScale = 0.5f, Fill = new Brush { Color = Color.Black }, }); var pointWithlabelStyle = new Feature { Geometry = new Point(0, 1000000)}; pointWithDefaultSymbolStyle.Styles.Add(new LabelStyle { Text = "Label" }); layer.DataSource = new MemoryProvider(new[] { pointWithlabelStyle, pointWithDefaultSymbolStyle, pointAsSmallBlackDot }); return layer; }
public void AddHexagon(Land land) { var zone = GeoHex.Decode(land.GeohexKey); var isOwn = Current.Instance.Earthwatcher.Lands.Any(x => x.GeohexKey == land.GeohexKey); var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords()); var polygon = new Polygon { ExteriorRing = new LinearRing(sphericalCoordinates) }; var feature = new Feature { Geometry = polygon }; feature["isGreenpeaceUser"] = land.EarthwatcherId.HasValue && land.EarthwatcherId.Value == Configuration.GreenpeaceId ? "True" : "False"; feature["hexcode"] = zone.code; bool ischecked = false; if (land.OKs.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString())) || land.Alerts.Split(',').Any(x => x.Equals(Current.Instance.Earthwatcher.Id.ToString()))) { ischecked = true; } bool denouncedByMe = false; if(Current.Instance.Scores.Any(x => x.Action.Equals(ActionPoints.Action.DemandAuthorities.ToString()) && (x.LandId == land.Id))) { denouncedByMe = true; } bool islockedOnly = land.IsLocked == true && land.DemandAuthorities == false ? true : false; feature.Styles.Add(GetVectorStyle(land.LandStatus, isOwn, land.DemandAuthorities, ischecked, land.EarthwatcherId.HasValue && land.EarthwatcherId.Value == Configuration.GreenpeaceId ? true : false, islockedOnly, denouncedByMe)); source.Features.Add(feature); }
private static Feature CreatePointWithDefaultStyle() { var feature = new Feature { Geometry = new Point(0, 0) }; feature.Styles.Add(new SymbolStyle()); feature.Styles.Add(new LabelStyle { Text = "Default Style", HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left }); return feature; }
public void AddHexagon(Zone zone, LandStatus landStatus, bool isOwnLand) { var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords()); var polygon = new Polygon { ExteriorRing = new LinearRing(sphericalCoordinates) }; var feature = new Feature {Geometry = polygon}; feature["hexcode"] = zone.code; feature.Styles.Add(GetVectorStyle(landStatus, isOwnLand)); source.Features.Add(feature); }
public void AddBasecamp(Land land) { var zone = GeoHex.Decode(land.GeohexKey); var isOwn = Current.Instance.Lands.Any(x => x.GeohexKey == land.GeohexKey); var sphericalCoordinates = ConvertHexCoordinates(zone.getHexCoords()); var polygon = new Polygon { ExteriorRing = new LinearRing(sphericalCoordinates) }; var feature = new Feature { Geometry = polygon }; feature["bccode"] = zone.code; _source.Features.Add(feature); }
private void DrawNames() { ClearNames(); //Cargo los puntos de cada finca if (_fincas != null) { foreach (var f in _fincas) { var sphericalMid = SphericalMercator.FromLonLat(f.Longitude, f.Latitude); var feature = new Feature { Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y) }; var res = Current.Instance.MapControl.Viewport.Resolution; //Cargo las distintas imagenes a niveles de zoom if (res > 2.79 && res <= 19.21) { var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/"+f.Id.ToString()+"_1.png"), SymbolType = SymbolType.Rectangle }; feature.Styles.Add(symbolStyle); _source.Features.Add(feature); } //else if (res > 19.21 && res <= 38.22) else if (res > 19.21 && res <= 305) { var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_2.png"), SymbolType = SymbolType.Rectangle }; feature.Styles.Add(symbolStyle); _source.Features.Add(feature); } //else if (res > 38.22 && res <= 76.48) //{ // var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_3.png"), SymbolType = SymbolType.Rectangle }; // feature.Styles.Add(symbolStyle); // _source.Features.Add(feature); //} //else if (res > 76.48 && res <= 153) //{ // var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_4.png"), SymbolType = SymbolType.Rectangle }; // feature.Styles.Add(symbolStyle); // _source.Features.Add(feature); //} //else if (res > 153 && res <= 305) //{ // var symbolStyle = new SymbolStyle { Symbol = GetSymbol("../Images/FincasName/" + f.Id.ToString() + "_5.png"), SymbolType = SymbolType.Rectangle }; // feature.Styles.Add(symbolStyle); // _source.Features.Add(feature); //} } } Current.Instance.MapControl.OnViewChanged(true); }
private static MemoryLayer CreatePointLayer() { var provider = new MemoryProvider(); var random = new Random(); for (var i = 0; i < 100; i++) { var feature = new Feature { Geometry = new Geometries.Point(random.Next(100000, 5000000), random.Next(100000, 5000000)) }; provider.Features.Add(feature); } return new MemoryLayer { DataSource = provider }; }
public static MemoryProvider CreateLineProvider() { var provider = new MemoryProvider(new Features()); var feature = new Feature { Geometry = Geometry.GeomFromText( "LINESTRING (-642227.831499647 5123550.9224083, -1241640.47423265 5037920.54487501, -1584161.9843658 4923746.70816396, -1869596.57614342 4923746.70816396, -2012313.87203223 4838116.33063068, -2326291.92298761 4809572.87145292, -2583183.05558747 4723942.49391963, -3211139.15749824 4695399.03474187, -3468030.2900981 4552681.73885306, -3610747.58598691 4524138.27967529, -3753464.88187572 4409964.44296425, -3810551.80023124 4409964.44296425, -4124529.85118663 4095986.39200886, -4181616.76954215 4095986.39200886, -4267247.14707544 4010356.01447558, -4467051.36131977 3924725.63694229, -4524138.2796753 3839095.259409, -4923746.70816397 3553660.66763138, -5066464.00405278 3525117.20845362, -5152094.38158606 3439486.83092033, -5237724.75911935 3268226.07585376, -5466072.43254144 3125508.77996495, -5523159.35089697 2982791.48407614, -5780050.48349683 2668813.43312076, -5979854.69774116 2354835.38216537, -6008398.15691892 2240661.54545433, -6065485.07527445 2183574.6270988, -6122571.99362997 1898140.03532118, -6236745.83034102 1755422.73943237, -6265289.28951878 1612705.44354356, -6322376.20787431 842032.045743983, -6322376.20787431 -642227.831499647, -6265289.28951878 -1041836.25998832, -6151115.45280774 -1527075.06601027, -5865680.86103011 -2240661.54545433, -5751507.02431907 -2383378.84134314, -5694420.10596354 -2526096.13723195, -5551702.81007473 -2668813.43312076, -5523159.35089697 -2754443.81065404, -5009377.08569725 -3239682.616676, -4781029.41227515 -3353856.45338705, -4609768.65720858 -3382399.91256481, -4295790.6062532 -3553660.66763138, -3525117.20845362 -3810551.80023124, -3325312.99420929 -3953269.09612005, -2554639.59640971 -4153073.31036439, -2069400.79038775 -4324334.06543096, -984749.341632795 -4524138.27967529, -670771.29067741 -4609768.65720858, -185532.484655455 -4809572.87145291, 271162.862188738 -4895203.2489862, 870575.504921742 -5180637.84076382, 1641248.90272132 -5437528.97336368, 1869596.57614342 -5551702.81007473, 2297748.46380985 -5637333.18760802, 2725900.35147628 -5637333.18760802, 3353856.45338705 -5694420.10596354, 4980833.62651949 -5722963.5651413, 4980833.62651949 -5694420.10596354, 5180637.84076382 -5665876.64678578, 5237724.75911935 -5608789.72843025, 5665876.64678578 -5523159.35089697, 5922767.77938564 -5323355.13665263, 6293832.74869654 -5209181.29994159, 6465093.50376312 -5095007.46323054, 6579267.34047417 -5095007.46323054, 6779071.5547185 -5009377.08569725, 6893245.39142955 -4895203.2489862, 7321397.27909598 -4866659.78980844, 7492658.03416255 -4809572.87145291, 7749549.16676241 -4809572.87145291, 8377505.26867318 -4638312.11638634, 8891287.53387289 -4609768.65720858, 9262352.5031838 -4723942.49391963, 9604874.01331695 -5037920.54487501, 9690504.39085023 -5066464.00405278, 9861765.14591681 -5266268.21829711, 10204286.65605 -5494615.89171921, 10946416.5946718 -5751507.02431907, 11888350.7475379 -5922767.77938564, 12830284.9004041 -5979854.69774116, 14971044.3387362 -5979854.69774116, 15427739.6855804 -5894224.32020788, 15741717.7365358 -5751507.02431907, 15770261.1957136 -5694420.10596354, 15827348.1140691 -5694420.10596354, 16226956.5425578 -5180637.84076382, 16369673.8384466 -4524138.27967529, 16483847.6751576 -4295790.6062532, 16512391.1343354 -4295790.6062532, 16540934.5935131 -4153073.31036439, 16598021.5118687 -4067442.9328311, 16626564.9710464 -3867638.71858677, 16769282.2669352 -3610747.58598691, 16797825.726113 -2811530.72900957, 16854912.6444685 -2611726.51476523, 16854912.6444685 -2383378.84134314, 16911999.5628241 -2240661.54545433, 16940543.0220018 -1726879.28025461, 17026173.3995351 -1555618.52518803, 17140347.2362461 -1469988.14765475, 17197434.1546017 -1327270.85176594, 17654129.5014459 -727858.209032934, 17739759.8789792 -528053.994788598, 17739759.8789792 -356793.239722027)") }; feature.Styles.Add(new VectorStyle { Line = new Pen(Color.Violet, 5) }); provider.Features.Add(feature); return provider; }
private static MemoryProvider CreateRandomPointsProvider(BoundingBox box) { var randomPoints = PointLayerSample.GenerateRandomPoints(box, 200); var features = new Features(); var count = 0; foreach (var point in randomPoints) { var feature = new Feature { Geometry = point }; feature["Label"] = count.ToString(CultureInfo.InvariantCulture); features.Add(feature); count++; } return new MemoryProvider(features); }
public static MemoryProvider CreatePolygonProvider() { var provider = new MemoryProvider(new Features()); var feature = new Feature { Geometry = Geometry.GeomFromText( "POLYGON ((-1955226.9536767 4267247.14707544, -2183574.6270988 4267247.14707544, -2611726.51476523 4095986.39200886, -2868617.64736509 4067442.9328311, -3268226.07585376 3896182.17776453, -3667834.50434243 3839095.259409, -4067442.9328311 3639291.04516467, -4495594.82049753 3525117.20845362, -4809572.87145292 3068421.86160943, -5066464.00405278 2954248.02489838, -5266268.21829711 2668813.43312076, -5780050.48349683 2240661.54545433, -6008398.15691892 1612705.44354356, -6265289.28951878 1070379.71916608, -6293832.74869655 813488.586566221, -6408006.58540759 642227.831499647, -6579267.34047417 -299706.321366502, -6779071.5547185 -984749.341632793, -6893245.39142955 -1755422.73943237, -6921788.85060731 -2982791.48407614, -6978875.76896284 -3296769.53503152, -6950332.30978507 -4866659.78980844, -6750528.09554074 -5922767.77938564, -6522180.42211864 -6522180.42211864, -6408006.58540759 -6721984.63636298, -6122571.99362997 -6950332.30978507, -6008398.15691892 -7378484.1974515, -5751507.02431907 -7692462.24840689, -5152094.38158606 -8234787.97278437, -4923746.70816397 -8348961.80949542, -3667834.50434243 -8634396.40127304, -2954248.02489838 -8720026.77880632, -899118.964099508 -8777113.69716185, -156989.025477692 -8834200.61551737, 1213097.01505489 -8834200.61551737, 2697356.89229852 -8777113.69716185, 3810551.80023124 -8634396.40127304, 4552681.73885306 -8291874.89113989, 4838116.33063068 -8120614.13607332, 5209181.29994158 -8006440.29936227, 5351898.5958304 -7920809.92182898, 5551702.81007473 -7635375.33005136, 5780050.48349683 -7521201.49334032, 5922767.77938564 -7292853.81991822, 6094028.53445221 -7150136.52402941, 6322376.20787431 -7035962.68731836, 6607810.79965193 -6779071.5547185, 6721984.63636298 -6522180.42211864, 7064506.14649612 -6065485.07527445, 7093049.60567388 -5894224.32020788, 7178679.98320717 -5694420.10596354, 7178679.98320717 -4923746.70816396, 7093049.60567388 -3981812.55529781, 6978875.76896283 -3496573.74927586, 6921788.85060731 -2925704.56572062, 6921788.85060731 -2611726.51476523, 7007419.2281406 -2497552.67805418, 7007419.2281406 -2440465.75969866, 8291874.89113989 -2155031.16792104, 10118656.2785167 -1898140.03532118, 11288938.1048049 -1555618.52518803, 12116698.42096 -870575.504921744, 12230872.2576711 -613684.372321885, 12373589.5535599 -442423.617255311, 12516306.8494487 -99902.1071221679, 12544850.3086264 642227.831499647, 12544850.3086264 4838116.33063068, 12573393.7678042 5009377.08569725, 12687567.6045153 5380442.05500816, 12915915.2779374 5665876.64678578, 13058632.5738262 5780050.48349683, 13429697.5431371 6293832.74869655, 13515327.9206704 6664897.71800745, 13515327.9206704 7035962.68731836, 13258436.7880705 7464114.57498479, 13030089.1146484 7492658.03416255, 12744654.5228708 7635375.33005136, 12544850.3086264 7692462.24840689, 11060590.4313828 7721005.70758465, 10889329.6763162 7635375.33005136, 10689525.4620719 7492658.03416255, 10575351.6253609 7292853.81991822, 10489721.2478276 7007419.2281406, 10375547.4111165 6864701.93225179, 10289917.0335832 6550723.8812964, 10204286.65605 6408006.58540759, 9947395.5234501 5437528.97336368, 9661960.93167247 4695399.03474187, 9604874.01331695 4381420.98378648, 9148178.66647276 4038899.47365334, 8948374.45222842 3953269.09612005, 8605852.94209528 3724921.42269796, 8206244.5136066 3667834.50434243, 7835179.5442957 3553660.66763138, 7606831.8708736 3553660.66763138, 7407027.65662927 3439486.83092033, 7150136.52402941 3382399.91256481, 6522180.42211864 3325312.99420929, 5951311.2385634 3154052.23914271, 4010356.01447558 3154052.23914271, 3239682.616676 3325312.99420929, 2811530.72900957 3353856.45338705, 2697356.89229852 3410943.37174257, 2212118.08627656 3496573.74927586, 2012313.87203223 3582204.12680915, 1469988.14765475 3639291.04516467, 1327270.85176594 3724921.42269796, 956205.882455029 3753464.88187572, 585140.913144123 3867638.71858677, -528053.994788598 3924725.63694229, -984749.341632795 4067442.9328311, -1070379.71916608 4124529.85118663, -1156010.09669936 4124529.85118663, -1156010.09669936 4153073.31036439, -1612705.44354356 4153073.31036439, -1869596.57614342 4210160.22871991, -1955226.9536767 4267247.14707544, -1955226.9536767 4267247.14707544))") }; feature.Styles.Add(new VectorStyle { Fill = new Brush(Color.Black), Line = new Pen(Color.Black, 3), Outline = new Pen(Color.Orange, 3) }); provider.Features.Add(feature); return provider; }
private static MemoryLayer CreateRandomPointLayer() { var provider = new MemoryProvider(); var rnd = new Random(); for (var i = 0; i < 100; i++) { var feature = new Feature { Geometry = new Geometries.Point(rnd.Next(0, 5000000), rnd.Next(0, 5000000)) }; provider.Features.Add(feature); } var layer = new MemoryLayer {DataSource = provider}; return layer; }
private static Feature CreateBitmapPoint() { var feature = new Feature { Geometry = new Point(0, 1000000) }; var bitmapId = BitmapRegistry.Instance.Register( System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Mapsui.Samples.Common.Images.loc.png")); feature.Styles.Add(new SymbolStyle { BitmapId = bitmapId, SymbolType = SymbolType.Ellipse, UnitType = UnitType.Pixel, SymbolScale = 0.5 }); return feature; }
public override IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution) { var geometries = PointLayerSample.GenerateRandomPoints(box, 10).ToList(); var count = 0; var random = _random.Next(geometries.Count()); foreach (var geometry in geometries) { if (count != random) // skip a random element to test robustness { var feature = new Feature {Geometry = geometry}; feature["ID"] = count.ToString(CultureInfo.InvariantCulture); yield return feature; } count++; } }
private static Feature CreateFeatureWithRotatedBitmapSymbol(double x, double y, double rotation) { const string bitmapPath = @"Mapsui.Tests.Common.Resources.Images.iconthatneedsoffset.png"; var bitmapStream = typeof(Utilities).GetTypeInfo().Assembly.GetManifestResourceStream(bitmapPath); var bitmapId = BitmapRegistry.Instance.Register(bitmapStream); var feature = new Feature {Geometry = new Point(x, y)}; feature.Styles.Add(new SymbolStyle { BitmapId = bitmapId, SymbolOffset = new Offset {Y = -24}, SymbolRotation = rotation }); return feature; }
private static MemoryProvider CreateRandomPointsProvider(IEnumerable<IGeometry> randomPoints) { var features = new Features(); var count = 0; foreach (var point in randomPoints) { var feature = new Feature { Geometry = point, [LabelColumn] = count.ToString(CultureInfo.InvariantCulture) }; features.Add(feature); count++; } return new MemoryProvider(features); }
public static IProvider Create() { var netherlands = new Feature { Geometry = new Point(710000, 6800000)}; const string resource = "Mapsui.Samples.Common.Images.netherlands.jpg"; var bitmapDataStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resource); netherlands.Styles.Add(new SymbolStyle { BitmapId = BitmapRegistry.Instance.Register(bitmapDataStream), SymbolType = SymbolType.Rectangle, UnitType = UnitType.WorldUnit, SymbolRotation = 5f, SymbolScale = 1400 }); return new MemoryProvider(netherlands); }
private void DrawJaguar() { var jaguarGame = Current.Instance.JaguarGame; if (jaguarGame != null) { ClearJaguar(); var sphericalMid = SphericalMercator.FromLonLat(jaguarGame.Longitude, jaguarGame.Latitude); var feature = new Feature { Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y) }; var symbolStyle = new SymbolStyle { Symbol = GetSymbol("jaguar.png"), SymbolType = SymbolType.Rectangle }; feature.Styles.Add(symbolStyle); _source.Features.Add(feature); Current.Instance.MapControl.OnViewChanged(true); } }
public static ILayer CreateLayer() { var memoryProvider = new MemoryProvider(); var featureWithDefaultStyle = new Feature {Geometry = new Point(0, 0)}; featureWithDefaultStyle.Styles.Add(CreateDefaultLabelStyle()); memoryProvider.Features.Add(featureWithDefaultStyle); var featureWithRightAlignedStyle = new Feature {Geometry = new Point(0, -2000000)}; featureWithRightAlignedStyle.Styles.Add(CreateRightAlignedLabelStyle()); memoryProvider.Features.Add(featureWithRightAlignedStyle); var featureWithColors = new Feature {Geometry = new Point(0, -4000000)}; featureWithColors.Styles.Add(CreateColoredLabelStyle()); memoryProvider.Features.Add(featureWithColors); return new MemoryLayer {Name = "Points with labels", DataSource = memoryProvider}; }
private static IFeature CreatePointWithSmallBlackDot() { var feature = new Feature { Geometry = new Point(1000000, 0) }; feature.Styles.Add(new SymbolStyle { SymbolScale = 2.0f, Fill = new Brush { Color = null }, Outline = new Pen { Color = Color.Green } }); feature.Styles.Add(new SymbolStyle { SymbolScale = 0.5f, Fill = new Brush { Color = Color.Black }, }); return feature; }
private static ILayer CreatePolygonLayer() { var layer = new MemoryLayer {Name = PolygonLayerName}; var provider = new MemoryProvider(); var feature = new Feature { Geometry = new Polygon(new LinearRing(new[] { new Point(1000000, 1000000), new Point(1000000, -1000000), new Point(-1000000, -1000000), new Point(-1000000, 1000000), new Point(1000000, 1000000) })), ["Name"] = "Polygon 1" }; provider.Features.Add(feature); layer.DataSource = provider; return layer; }
public static ILayer Create() { var layer = new Layer("PointLayer WorldUnits"); var netherlands = new Feature { Geometry = new Point(710000, 6800000)}; const string resource = "Mapsui.Samples.Common.Images.netherlands.jpg"; netherlands.Styles.Add(new SymbolStyle { Symbol = new Bitmap { Data = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resource) }, SymbolType = SymbolType.Rectangle, UnitType = UnitType.WorldUnit, SymbolRotation = 5f, SymbolScale = 1400, Width = 365, Height = 380 }); layer.DataSource = new MemoryProvider(new[] { netherlands }); return layer; }
public void DeleteFeatureReferenceType() { // Arrange const string keyField = "thekeyfield"; var features = new Features(keyField); var feature1 = new Feature(); feature1[keyField] = "a"; features.Add(feature1); var feature2 = new Feature(); feature2[keyField] = "b"; features.Add(feature2); // Act var first = features.First(f => f[keyField].Equals("a")); features.Delete(first[keyField]); // Assert Assert.IsFalse(features.Any(f => f[keyField].Equals("a"))); }
public static IProvider CreateProvider() { var netherlands = new Feature {Geometry = new Point(710000, 6800000)}; const string resource = "Mapsui.Samples.Common.Images.netherlands.jpg"; var assembly = typeof(SymbolsInWorldUnitsSample).GetTypeInfo().Assembly; var bitmapDataStream = assembly.GetManifestResourceStream(resource); netherlands.Styles.Add(new SymbolStyle { BitmapId = BitmapRegistry.Instance.Register(bitmapDataStream), SymbolType = SymbolType.Rectangle, UnitType = UnitType.WorldUnit, SymbolRotation = 5f, SymbolScale = 1400 }); netherlands.Styles.Add(new LabelStyle { Text = "Style in world units", HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left }); return new MemoryProvider(netherlands); }
private void DrawMarkers(IEnumerable<Land> landPieces) { if (landPieces == null) return; ClearGraphics(); foreach (var land in landPieces) { var sphericalMid = SphericalMercator.FromLonLat(land.Longitude, land.Latitude); var feature = new Feature { Geometry = new Mapsui.Geometries.Point(sphericalMid.x, sphericalMid.y) }; var symbolStyle = new SymbolStyle { Symbol = GetSymbol("warning.png"), SymbolType = SymbolType.Rectangle}; feature.Styles.Add(symbolStyle); source.Features.Add(feature); } Current.Instance.MapControl.OnViewChanged(true); }
public TestLayer(string name) : base(name) { _source = new MemoryProvider(); DataSource = _source; List<Location> locations = new List<Location>(); locations.Add(new Location(-63.307, -23.203)); locations.Add(new Location(-63.200, -23.203)); locations.Add(new Location(-63.200, -23.350)); locations.Add(new Location(-63.307, -23.350)); locations.Add(new Location(-63.307, -23.203)); var polygon = new Polygon { ExteriorRing = new LinearRing(ConvertHexCoordinates(locations)) }; var feature = new Feature { Geometry = polygon }; var color = Color.Blue; if (name.Equals("08-may")) { color = Color.Green; } else if (name.Equals("03-jun")) { color = Color.Red; } var vStyle = new VectorStyle { Fill = new Brush { Color = color }, Outline = new Pen { Color = Color.Black, Width = 0 }, }; feature.Styles.Add(vStyle); _source.Features.Add(feature); //Current.Instance.MapControl.OnViewChanged(true); }
private static List<IFeature> TileIndexToFeatures(TileIndex[] tileIndexes, ITileSource tileSource) { var features = new List<IFeature>(); foreach (var tileIndex in tileIndexes) { var tileInfo = new TileInfo { Index = tileIndex, Extent = TileTransform.TileToWorld( new TileRange(tileIndex.Col, tileIndex.Row), tileIndex.Level, tileSource.Schema) }; var feature = new Feature { Geometry = new Raster(new MemoryStream( tileSource.GetTile(tileInfo)), tileInfo.Extent.ToBoundingBox()) }; features.Add(feature); } return features; }
private static IFeature CreatePointWithStackedStyles() { var feature = new Feature { Geometry = new Point(0, -1000000) }; feature.Styles.Add(new SymbolStyle { SymbolScale = 2.0f, Fill = new Brush { Color = null }, Outline = new Pen { Color = Color.Green } }); feature.Styles.Add(new SymbolStyle { SymbolScale = 0.5f, Fill = new Brush { Color = Color.Black } }); feature.Styles.Add(new LabelStyle { Text = "Stacked Styles", HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left}); return feature; }
private static ILayer CreateMutatingTriangleLayer(BoundingBox envelope) { var layer = new MemoryLayer(); var polygon = new Polygon(new LinearRing(GenerateRandomPoints(envelope, 3))); var feature = new Feature() { Geometry = polygon }; var features = new Features(); features.Add(feature); layer.DataSource = new MemoryProvider(features); PeriodicTask.Run(() => { polygon.ExteriorRing = new LinearRing(GenerateRandomPoints(envelope, 3)); // Clear cache for change to show feature.RenderedGeometry.Clear(); // Trigger DataChanged notification layer.ViewChanged(true, layer.Envelope, 1); }, TimeSpan.FromMilliseconds(1000)); return layer; }