https://github.com/nora-soderlund/coordinateprojection
An itsy-bitsy-teenie-weenie-tiny package to project coordinates into screen points where the map boundaries are already defined.
https://github.com/nora-soderlund/coordinateprojection
Last synced: about 1 year ago
JSON representation
An itsy-bitsy-teenie-weenie-tiny package to project coordinates into screen points where the map boundaries are already defined.
- Host: GitHub
- URL: https://github.com/nora-soderlund/coordinateprojection
- Owner: nora-soderlund
- Archived: true
- Created: 2023-01-20T15:49:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-20T15:57:23.000Z (over 3 years ago)
- Last Synced: 2025-02-07T17:18:35.404Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CoordinateProjection
An itsy-bitsy-teenie-weenie-tiny package to project coordinates into screen points where the map boundaries are already defined.
## Example
```csharp
public partial class MyForm : Form {
private readonly CoordinateBounds staticMapBounds = new () {
East = 153.32191748046876f,
North = -33.50848555239759f,
South = -35.27618036073599f,
West = 147.96608251953126f
};
private List Coordinates = new List() {
new (-33.86883898636453f, 151.20914864607147f), // Sydney
new (-34.82777280506466f, 148.90830590294317f), // Yass
new (-34.66920061357916f, 150.852685799046f), // Kiama
new (-34.424845374813025f, 150.89311318548945f) // Wollongong
};
public MyForm() {
InitializeComponent();
ScreenProjection screenProjection = new(staticMap.Width, staticMap.Height, staticMapBounds);
Image image = new Bitmap(staticMap.Width, staticMap.Height);
using (var graphics = Graphics.FromImage(image)) {
graphics.DrawImage(Resources.Resources.static_map, new Rectangle(0, 0, staticMap.Width, staticMap.Height));
foreach (Coordinate coordinate in Coordinates) {
ScreenPoint point = screenProjection.GetScreenPoint(coordinate);
graphics.DrawImage(Resources.Resources.pin, new Rectangle(point.Left, point.Top - 20, 20, 20));
}
}
staticMap.Image = image;
}
}
```
