How to make an image of a country on the globe using a sharp map

I have a list of area boundaries inside an SQL database, and I use sharpmap to render thumbnails for each country I need. It works very well.

But I would like to take another step and add a small globe around it and place the country on it in the world, but I do not know where to start.

Here is the code that I use so far to display the thumbs of the country. Any ideas?

var map = new Map(new Size(command.Width, command.Height));
map.BackColor = Color.Transparent;
var countryGeometry = GeometryFromWKT.Parse(command.CountryLevelWkt);
IProvider countryProvider = new GeometryFeatureProvider(countryGeometry);
var countryLayer = new VectorLayer("country", countryProvider);
var borderColor = System.Drawing.ColorTranslator.FromHtml(command.BorderColor);
countryLayer.Style.EnableOutline = true;
countryLayer.Style.Outline = new Pen(borderColor);
countryLayer.Style.Outline.Width = command.BorderWidth;
countryLayer.Style.Fill = Brushes.Transparent;

var transformationFactory = new CoordinateTransformationFactory();
countryLayer.CoordinateTransformation = transformationFactory.CreateFromCoordinateSystems(
            GeographicCoordinateSystem.WGS84,
            ProjectedCoordinateSystem.WebMercator);
map.Layers.Add(countryLayer);
var bottomLeft = new Coordinate(command.Extents.BottomLeft.Longitude, command.Extents.BottomLeft.Latitude);
var topRight = new Coordinate(command.Extents.TopRight.Longitude, command.Extents.TopRight.Latitude);


// transformations
var bottomLeftLongLat = countryLayer.CoordinateTransformation.MathTransform.Transform(bottomLeft);
var topRightLongLat = countryLayer.CoordinateTransformation.MathTransform.Transform(topRight);
map.ZoomToBox(new Envelope(bottomLeftLongLat, topRightLongLat));
             var img = map.GetMap();
return img;
+4
source share
1 answer
  • Start by drawing all countries on a new map, each on its own layer.
  • Draw the country in which you are interested in on your own layer.
  • Envelope.Center 2. , , .
  • . sufrace (System.Drawing.Graphics).
  • , . , , . .
  • 5 . sufrace (. 4).
  • 5-6, / , 3.

: Map Form Sample

, :

  • .
  • ( )
  • (, ) Envelope.Center -

Windows Forms. http://thematicmapping.org/downloads/world_borders.php.

+2

Source: https://habr.com/ru/post/1687018/


All Articles