javafxdrawingjavafx-2drawing2d

Drawing 2D maps in JavaFX


I'm currently working on project that uses json file with points & polygons.

All input data are a Lat/Lon format. I wish to draw these on a map (Which should be able to pan). I'm able to draw these objects on a JavaFx Pane or Canvas.

The issue is the data line between two coordinates is a straight line while it actually should follow stereographic projection .

I looked into ArcGis and other GeoTools but these tools all build upon tile maps something I don't need for my project.


Solution

  • You will have to create something what we call a LineDrawer. First you have to determine what line type you want to use. Standard line types are great-circle, rhumb and just straight lines. Second you have to define the projection you want to use. So if you now want to draw a line between two points A and B you have to split this up into small enough sections and compute intermediate points according to the formula for your chosen line type and then you have to project these points into your drawing pane. But that's basically what every GIS software can do for you and you don't have to re-invent the wheel here.