- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 sharpmap 将来自 MSSQL 的边界(几何)渲染为 PNG 图像。这一切都很好,除了一些国家在平面图像格式上看起来太“宽”。
据我了解,我需要创建到 EPSG:3857 投影的转换,但我不知道该怎么做。
这是我的代码
var map = new Map(new Size(request.Width, request.Height));
map.BackColor = Color.Transparent;
var countryGeometry = GeometryFromWKT.Parse(dto.CountryWkt);
IProvider countryProvider = new GeometryFeatureProvider(countryGeometry);
var countryLayer = new VectorLayer("country", countryProvider);
var borderColor = System.Drawing.ColorTranslator.FromHtml("#525252");
countryLayer.Style.EnableOutline = true;
countryLayer.Style.Outline = new Pen(borderColor);
countryLayer.Style.Fill = Brushes.Transparent;
//does not work with this
countryLayer.CoordinateTransformation = new
ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory().CreateFromCoordinateSystems(
ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
map.Layers.Add(countryLayer);
map.ZoomToBox(new Envelope(dto.Envelope.BottomLeft.Longitude,
dto.Envelope.TopRight.Longitude,
dto.Envelope.BottomLeft.Latitude,
dto.Envelope.TopRight.Latitude
));
var img = map.GetMap();
可以在这里找到 WKT https://pastebin.com/PEbpAdxT
感谢任何帮助。
编辑:这是我现在为法国及其“Limousin”地区获得的图像。如您所见,它太“宽”了。
这是我应用转换时的图像,可以在代码注释下找到 does not work with this
编辑 2
我也尝试过跟随进行转换,但这会呈现空白 png(上面没有红叉)
public ICoordinateTransformation Wgs84toGoogleMercator
{
get
{
if (_wgs84ToGoogle == null)
{
CoordinateSystemFactory csFac = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
IGeographicCoordinateSystem wgs84 = csFac.CreateGeographicCoordinateSystem(
"WGS 84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich,
new AxisInfo("north", AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East));
// var a = csFac.CreateFromWkt("aa");
List<ProjectionParameter> parameters = new List<ProjectionParameter>();
parameters.Add(new ProjectionParameter("semi_major", 6378137.0));
parameters.Add(new ProjectionParameter("semi_minor", 6378137.0));
parameters.Add(new ProjectionParameter("latitude_of_origin", 0.0));
parameters.Add(new ProjectionParameter("central_meridian", 0.0));
parameters.Add(new ProjectionParameter("scale_factor", 1.0));
parameters.Add(new ProjectionParameter("false_easting", 0.0));
parameters.Add(new ProjectionParameter("false_northing", 0.0));
IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters);
IProjectedCoordinateSystem epsg900913 = csFac.CreateProjectedCoordinateSystem(
"Google Mercator", wgs84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East),
new AxisInfo("North", AxisOrientationEnum.North));
((CoordinateSystem)epsg900913).DefaultEnvelope = new [] { -20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789 };
_wgs84ToGoogle = ctFac.CreateFromCoordinateSystems(wgs84, epsg900913);
}
return _wgs84ToGoogle;
}
}
最佳答案
您使用的
CoordinateTransformation
确实有效。
你得到空白图像是因为你的 ZoomToBox
坐标是错误的,所以它实际上显示了图像的空白部分。如果您改用 map.ZoomToExtents();
函数,在缩放之前查看整个图像,它看起来像这样:
现在,如果我在浏览器中手动缩放以获取应用此变换后法国的特写图像,您可以看到它实际上不再被拉伸(stretch)了。
作为结论,我会说您只需要修复您的 ZoomToBox
坐标,一切都会正常进行。希望能帮助到你。 :)
关于c# - 转换 EPSG :4326 projection to EPSG:3857 mercator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44625176/
在开放层我们可以简单地将 EPSG:900913 转换为 EPSG:4326 我正在寻找可以做到这一点的 java 库。 在这里我发现了这个, http://www.jhlabs.com/java/m
我目前正在尝试弄清楚 vesselfinder.com 如何计算其用于从后端查询数据的框边界 (bbox)。 给定如下输入:lat, lon = 59.8230, 22.9586 他们使用这个 bbo
我从 here 获得了邮政编码周长的 shapefile并想将它们绘制在 Cartopy map 上,就像我在 this example 中所做的那样. 根据消息来源,该数据采用 EPSG 4326
我正在使用 sharpmap 将来自 MSSQL 的边界(几何)渲染为 PNG 图像。这一切都很好,除了一些国家在平面图像格式上看起来太“宽”。 据我了解,我需要创建到 EPSG:3857 投影的转换
如何使用 geotools 或其他 Java 库将经纬度投影转换为 EPSG 3857 投影?我无法找到正确的使用方法。我知道 OpenLayers (javascript) 可以轻松做到这一点,但我
我需要将 GeoJSON 矢量数据从 EPSG:4326 转换为 EPSG:3857 ... 我有 map ... var olMapDiv = document.getElementById('ol
目前,我正在使用 Mono4Droid 实现一个 map 应用程序,并且我正在使用 WebView 来呈现由我自己的 tileserver 提供的 map 。我正在使用 OpenLayers 来显示这
我一直在使用来自 https://ariasprado.name/2012/08/13/quick-and-dirty-coordinate-transforming-using-geotools.h
我在从韩国 2000 坐标系 (EPSG:5179) 转换为十进制度 (EPSG:4326) 时遇到问题。 我们正在为韩国公司开发地理信息系统。我们将 Geotools 库用于多个后端实现。但是,我现
我正在使用带有图层的 map (来自示例): var lonLat = new OpenLayers.LonLat(40.4088576, -86.8576718) .
给定一个 (lon, lat) 点 (5.068913, 52.067567),我想使用 pyproj 从 EPSG 4326 转换为 EPSG 28992。 pyproj 中的Proj 和trans
我正在从 OpenLayers 迁移到 Leaflet 库,但遇到了以下问题: OpenLayers 代码将 EPSG:4326 坐标转换为 EPSG:3857 var arCoordinates =
我得到了使用 API 的说明,但我很难理解如何将坐标转换为正确的格式。根据 API 文档,我应该传递点或多边形点数组: To perform a point query, which finds th
我想知道一个可以用来从 4326 转换为 3857 的 Swift 库或方法。我引用了一些库,例如 Proj4Swift和 Proj.4 ,但无济于事。第一个链接没有可用的下载,第二个链接没有文档。有
我正在尝试使传单使用 EPSG:3857 作为输入坐标系。我使用 porj4leaflet 来实现这一点。我已经像这样定义了我的 map 实例: var map = L.map('map', { ce
我有一个 tfw 文件的 tif 文件 30.00000000 0.00000000 0.00000000 -30.00000000 4558664.95812873 4002879.73390
我想在我的传单应用程序中使用 EPSG:4326 CRS,因为我有很多仅在 EPSG:4326 中可用的 WMS 层。 因此,我正在 EPSG:4326 中寻找磁贴服务。但似乎我找到的所有 X/Y/Z
我有几个关于 PostGIS 中的几何和地理的问题。 我目前正在使用 PostGIS 和 Postgresql。 我的大部分空间数据都来自韩国,基本上是经纬度。 为了测试,我创建了两个具有相同纬度和经
我有几个关于 PostGIS 中的几何和地理的问题。 我目前正在使用 PostGIS 和 Postgresql。 我的大部分空间数据都来自韩国,基本上是经纬度。 为了测试,我创建了两个具有相同纬度和经
我的数据库中有一个 EPSG 3857 格式的坐标列表。我需要将它们转换为 EPSG 4326我正在尝试使用 DotSpatial,但我的代码总是重新调整无限大的双数组。 public double[
我是一名优秀的程序员,十分优秀!