本文整理汇总了C#中SharpMap.Map.ZoomToExtents方法的典型用法代码示例。如果您正苦于以下问题:C# SharpMap.Map.ZoomToExtents方法的具体用法?C# SharpMap.Map.ZoomToExtents怎么用?C# SharpMap.Map.ZoomToExtents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpMap.Map
的用法示例。
在下文中一共展示了SharpMap.Map.ZoomToExtents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeMap
public static SharpMap.Map InitializeMap(float angle)
{
var dataSource = new SharpMap.Data.Providers.ShapeFile(
string.Format("{0}/roads.shp", ShapefileSample.PathOsm), true);
var fds = new SharpMap.Data.FeatureDataSet();
dataSource.Open();
dataSource.ExecuteIntersectionQuery(dataSource.GetExtents(), fds);
dataSource.Close();
var gfp = new SharpMap.Data.Providers.GeometryFeatureProvider(fds.Tables[0]);
var vl = new SharpMap.Layers.VectorLayer("roads", gfp)
{
CoordinateTransformation = LayerTools.Dhdn2ToWgs84
};
var ll = new SharpMap.Layers.LabelLayer("labels")
{
DataSource = gfp,
CoordinateTransformation = LayerTools.Dhdn2ToWgs84,
LabelColumn = "name",
MultipartGeometryBehaviour =
SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest,
};
ll.Style.Halo = new System.Drawing.Pen(System.Drawing.Color.Red);
//ll.Style.IgnoreLength = true;
var map = new SharpMap.Map();
map.Layers.Add(vl);
map.Layers.Add(ll);
map.Layers.Add(vl);
map.ZoomToExtents();
return map;
}
示例2: render2d
public void render2d(Project project, PictureBox picBox)
{
SharpMap.Map myMap = new SharpMap.Map();
foreach (BuildLayer layer in project.getLayers())
{
Source source = layer.getSource();
BoundingBox envelope = new BoundingBox(-1000.0, -1000.0, 1000.0, 1000.0);//TODO
FeatureDataSet ds = new FeatureDataSet();
source.DataSource.Open();
source.DataSource.ExecuteIntersectionQuery(envelope, ds);
source.DataSource.Close();
FeatureDataTable features = (FeatureDataTable)ds.Tables[0];
string label = "Trace test:\n";
foreach (FeatureDataRow row in features)
{
foreach (Object item in row.ItemArray)
label += " - " + item;
label += "\n";
}
setLabel(label);
//Show map
//Filters
FilterGraph graph = project.getFilterGraph(source.getName());
if (graph != null)
{
foreach (FeatureFilter filter in graph.getFilters())
{
//aplicar filtro segun el tipo
Mogre.DefaultSceneManagerFactory dsmf = new DefaultSceneManagerFactory();
Mogre.SceneManager sm = dsmf.CreateInstance("scenemanager");
FilterEnv env = new FilterEnv(sm, "env");
foreach (MogreGis.Resource resource in project.getResources())
{
env.getSession().Resources.addResource(resource);
}
FeatureList list = Feature.DataTableToList(features);
filter.process(list, env);
//falta devolver la lista y procesarla ***************************************
}
}
SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer(layer.getName());
myLayer.DataSource = source.DataSource;
myMap.Layers.Add(myLayer);
}
myMap.Size = new Size(picBox.Width, picBox.Height);
myMap.ZoomToExtents();
picBox.Image = myMap.GetMap();
this.map = myMap;
}
示例3: InitializeMap
public static SharpMap.Map InitializeMap(float angle)
{
using (var ofn = new System.Windows.Forms.OpenFileDialog())
{
ofn.Filter = "All files|*.*";
ofn.FilterIndex = 0;
if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var m = new SharpMap.Map();
var l = new SharpMap.Layers.GdiImageLayer(ofn.FileName);
m.Layers.Add(l);
m.ZoomToExtents();
var mat = new System.Drawing.Drawing2D.Matrix();
mat.RotateAt(angle, m.WorldToImage(m.Center));
m.MapTransform = mat;
m.MaximumExtents = m.GetExtents();
m.EnforceMaximumExtents = true;
return m;
}
}
return null;
}
示例4: TestSymbolSelectionTheming
public void TestSymbolSelectionTheming()
{
//Create a map
SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720, 360));
//Create some random sample data
SharpMap.Data.FeatureDataTable fdt =
cd.CreatePointFeatureDataTableFromArrays(cd.GetRandomOrdinates(80, -180, 180),
cd.GetRandomOrdinates(80, -90, 90), null);
//Add rotation column and fill with random rotation values
fdt.Columns.Add("Symbol", typeof(System.Byte[]));
foreach (SharpMap.Data.FeatureDataRow row in fdt.Rows)
row["Symbol"] = RandomSymbol((int)System.Math.Floor(cd.RandomNumberGenerator.NextDouble() * 360d));
//Create layer and datasource
SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("Points", new SharpMap.Data.Providers.GeometryFeatureProvider(fdt));
//Create default style
SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle();
defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png");
defaultStyle.SymbolScale = 0.5f;
//Create theming class and apply to layer
SymbolFromFeatureDataRowTheming srt = new SymbolFromFeatureDataRowTheming("Symbol", defaultStyle);
vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(srt.GetRotatedSymol);
map.Layers.Add(vl);
map.ZoomToExtents();
System.Drawing.Image mapImage = map.GetMap();
mapImage.Save("SymbolFromFDR.bmp");
}
示例5: TestListPointSymbolizer
public void TestListPointSymbolizer()
{
var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
var pps =
SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue), 20);
var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
{
Halo = 1,
HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
Font = new System.Drawing.Font("Arial", 12),
CharacterIndex = 65
};
var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer { pps, cps };
layer.Style.PointSymbolizer = lps;
var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
map.Layers.Add(layer);
map.ZoomToExtents();
map.GetMap().Save("ListPointSymbolizer1.bmp");
}
示例6: TestCharacterPointSymbolizer
public void TestCharacterPointSymbolizer()
{
var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
var geometryFeatureProvider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
{
Halo = 1,
HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat),
//Font = new System.Drawing.Font("Arial", 12),
CharacterIndex = 0xcc,
};
layer.Style.PointSymbolizer = cps;
var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
map.Layers.Add(layer);
map.ZoomToExtents();
map.GetMap().Save("CharacterPointSymbolizer1.bmp");
cps.Rotation = -30;
cps.Offset = new System.Drawing.PointF(4, 4);
map.GetMap().Save("CharacterPointSymbolizer2.bmp");
cps.Font = new System.Drawing.Font("Arial", 12);
cps.Text = "ABC";
cps.Offset = System.Drawing.PointF.Empty;
cps.Rotation = -90;
map.GetMap().Save("CharacterPointSymbolizer3.bmp");
}
示例7: TestPathPointSymbolizer
public void TestPathPointSymbolizer()
{
var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
var pps =
SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue), 20);
layer.Style.PointSymbolizer = pps;
var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
map.Layers.Add(layer);
map.ZoomToExtents();
map.GetMap().Save("PathPointSymbolizer1.bmp");
pps.Rotation = -30;
map.GetMap().Save("PathPointSymbolizer2.bmp");
pps.Rotation = 0f;
pps.Offset = new System.Drawing.PointF(4, 4);
map.GetMap().Save("PathPointSymbolizer3.bmp");
var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();
gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
pps = new
SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
{
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle1,
Line =
new System.Drawing.Pen(
System.Drawing.Color.Red, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.DodgerBlue)
},
new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
{
Path = gpTriangle2,
Line =
new System.Drawing.Pen(
System.Drawing.Color.DodgerBlue, 2),
Fill =
new System.Drawing.SolidBrush(
System.Drawing.Color.Red)
}
}){ Rotation = 45 };
layer.Style.PointSymbolizer = pps;
map.GetMap().Save("PathPointSymbolizer4.bmp");
pps.Rotation = 180;
map.GetMap().Save("PathPointSymbolizer5.bmp");
}
示例8: InitializeMap
public static SharpMap.Map InitializeMap(int angle, string[] filenames)
{
var map = new SharpMap.Map();
for (int i = 0; i < filenames.Length; i++)
map.Layers.Add(new SharpMap.Layers.GdalRasterLayer(System.IO.Path.GetFileName(filenames[i]), filenames[i]));
System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
mat.RotateAt(angle, map.WorldToImage(map.Center));
map.MapTransform = mat;
map.ZoomToExtents();
return map;
}
示例9: TestRealData
public void TestRealData()
{
var fdt = GetRealFeatureDataTable();
FillRealDataTable(fdt);
var p = new SharpMap.Data.Providers.FeatureProvider(fdt);
var m = new SharpMap.Map(new Size(640, 640));
m.Layers.Add(new TileLayer(
new OsmTileSource(new OsmRequest(KnownTileServers.Mapnik) /*,
new FileCache(@"d:\temp\OSM", "png")*/), "OSM"));
var l = new HeatLayer(p, "Data", 0.001f);
l.LayerName = "HEAT";
m.Layers.Add(l);
#if DotSpatialProjections
l.CoordinateTransformation = new DotSpatial.Projections.CoordinateTransformation
{
Source = ProjectionInfo.FromEpsgCode(4326),
Target = ProjectionInfo.FromEpsgCode(3857)
};
#else
var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
l.CoordinateTransformation =
ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
#endif
l.ZoomMin = 0;// 0.01 * m.GetExtents().Width;
l.ZoomMax = /*0.9 * */m.GetExtents().Width;
l.OpacityMax = 1;
l.OpacityMin = 0.3f;
m.ZoomToBox(l.Envelope);
for (var i = 0; i < 5; i++)
{
using (var img = m.GetMap())
{
img.Save("RealDataHeat" + i + ".png");
}
m.Zoom /= 2;
}
m.ZoomToExtents();
using (var img = m.GetMap())
{
img.Save("RealDataHeat.png");
}
}
示例10: TestWarpedLineSymbolizer
public void TestWarpedLineSymbolizer()
{
var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\GeoFabrik\\Aurich\\roads.shp", false);
var l = new SharpMap.Layers.VectorLayer("roads", p);
var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();
cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) });
cls.LineSymbolizeHandlers.Add(new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander { Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetGreaterSeries(3, 3), Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1) });
l.Style.LineSymbolizer = cls;
var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) {BackColor = System.Drawing.Color.Cornsilk};
m.Layers.Add(l);
m.ZoomToExtents();
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
var bmp = m.GetMap();
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
bmp.Save("AurichRoads1.bmp");
cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
{
Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetTriangleSeries(4, 7),
Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1),
Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick)
};
sw.Start();
bmp = m.GetMap();
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
bmp.Save("AurichRoads2.bmp");
//cls.LineSymbolizeHandlers[0] = cls.LineSymbolizeHandlers[1];
cls.LineSymbolizeHandlers[1] = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
{
Pattern = SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.GetZigZag(4, 4),
Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1),
//Fill = new System.Drawing.SolidBrush(System.Drawing.Color.Firebrick)
};
sw.Start();
bmp = m.GetMap();
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
bmp.Save("AurichRoads3.bmp");
}
示例11: TestPlainPolygonSymbolizer
public void TestPlainPolygonSymbolizer()
{
var provider = new SharpMap.Data.Providers.ShapeFile(
"..\\..\\..\\WinFormSamples\\GeoData\\World\\countries.shp", true);
var l = new SharpMap.Layers.Symbolizer.PolygonalVectorLayer("Countries", provider);
l.Symbolizer = new ModifiedBasicPolygonSymbolizer
{
Fill = new System.Drawing.Drawing2D.HatchBrush(
System.Drawing.Drawing2D.HatchStyle.WideDownwardDiagonal,
System.Drawing.Color.Red /*,
System.Drawing.Color.LightPink*/),
UseClipping = false,
//Outline = System.Drawing.Pens.AliceBlue
};
var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080)) { BackColor = System.Drawing.Color.Cornsilk };
m.Layers.Add(l);
m.ZoomToExtents();
var sw = new System.Diagnostics.Stopwatch();
var img = m.GetMap();
sw.Start();
img = m.GetMap();
img.Save("PolygonSymbolizer-1.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method:{0}ms", sw.ElapsedMilliseconds));
l.Symbolizer = new SharpMap.Rendering.Symbolizer.BasicPolygonSymbolizer()
{
Fill = new System.Drawing.Drawing2D.HatchBrush(
System.Drawing.Drawing2D.HatchStyle.WideDownwardDiagonal,
System.Drawing.Color.Red/*,
System.Drawing.Color.LightPink*/),
UseClipping = false,
//Outline = System.Drawing.Pens.AliceBlue
};
sw.Reset(); sw.Start();
img = m.GetMap();
img.Save("PolygonSymbolizer-2.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method:{0}ms", sw.ElapsedMilliseconds));
}
示例12: MultiLineCenterAlignedTest
public void MultiLineCenterAlignedTest()
{
using (var m = new SharpMap.Map(new Size(600, 400)))
{
m.BackColor = Color.SeaShell;
//_featureDataTable.Clear();
var gfp = new GeometryFeatureProvider(_featureDataTable);
var vl = new VectorLayer("VL", gfp);
var ll = new LabelLayer("MultiLineCenterAligned") {DataSource = gfp};
ll.Theme = CreateTheme();
ll.LabelColumn = "LABEL";
m.Layers.Add(vl);
m.Layers.Add(ll);
m.ZoomToExtents();
using (var mapImage = m.GetMap())
mapImage.Save("MultiLineCenterAligned.png", ImageFormat.Png);
}
}
示例13: TestPerformanceVectorLayer
public void TestPerformanceVectorLayer()
{
NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp")),
"Specified shapefile is not present!");
var map = new SharpMap.Map(new System.Drawing.Size(1024, 768));
var shp = new SharpMap.Data.Providers.ShapeFile(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp"));
var lyr = new SharpMap.Layers.VectorLayer("Roads", shp);
map.Layers.Add(lyr);
map.ZoomToExtents();
RepeatedRendering(map, shp.GetFeatureCount(), NumberOfRenderCycles, out _msVector);
var res = map.GetMap();
var path = System.IO.Path.ChangeExtension(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp"), ".vector.png");
res.Save(path, System.Drawing.Imaging.ImageFormat.Png);
System.Console.WriteLine("\nResult saved at file://" + path.Replace('\\', '/'));
}
示例14: TestCachedLineSymbolizerInTheme
public void TestCachedLineSymbolizerInTheme()
{
var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\GeoFabrik\\Aurich\\roads.shp", false);
var l = new SharpMap.Layers.VectorLayer("roads", p);
var theme = new ClsTheme(l.Style);
l.Theme = theme;
var m = new SharpMap.Map(new System.Drawing.Size(720, 540)) { BackColor = System.Drawing.Color.Cornsilk };
m.Layers.Add(l);
m.ZoomToExtents();
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
var bmp = m.GetMap();
sw.Stop();
System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
bmp.Save("AurichRoads1Theme.bmp");
}
示例15: TestEnsureVisible
public void TestEnsureVisible()
{
//Create a map
SharpMap.Map map = new SharpMap.Map(new System.Drawing.Size(720,360));
//Create some random sample data
SharpMap.Data.FeatureDataTable fdt =
cd.CreatePointFeatureDataTableFromArrays(cd.GetRandomOrdinates(80, -180, 180),
cd.GetRandomOrdinates(80, -90, 90), null);
//Create layer and datasource
SharpMap.Layers.VectorLayer vl = new SharpMap.Layers.VectorLayer("Points", new SharpMap.Data.Providers.FeatureProvider(fdt));
//Create default style
SharpMap.Styles.VectorStyle defaultStyle = new SharpMap.Styles.VectorStyle();
defaultStyle.Symbol = new System.Drawing.Bitmap(@"..\..\..\DemoWinForm\Resources\flag.png");
defaultStyle.SymbolScale = 0.5f;
//Create theming class and apply to layer
var srt = new SymbolRotationTheming("Rotation", defaultStyle);
vl.Theme = new SharpMap.Rendering.Thematics.CustomTheme(srt.GetRotatedSymol);
map.Layers.Add(vl);
map.ZoomToExtents();
map.Zoom = 60; //2*30
map.Center = new GeoAPI.Geometries.Coordinate(0,0);
System.Console.WriteLine(map.Center);
EnsureVisible(map, new GeoAPI.Geometries.Coordinate(-30, 0));
System.Console.WriteLine(map.Center);
System.Console.WriteLine();
EnsureVisible(map, new GeoAPI.Geometries.Coordinate(15, 20));
System.Console.WriteLine(map.Center);
System.Console.WriteLine();
EnsureVisible(map, new GeoAPI.Geometries.Coordinate(15, -20));
System.Console.WriteLine(map.Center);
}