I need to print a polygon given a set of Longitude and Latitude coordinates. I am starting with just two coordinate for initial testing. The problem is Java Image API works on pixel points and that Longitude and Latitude are big decimals.
So even if I have this code:
BufferedImage bi = new BufferedImage(500, 500, BufferedImage.OPAQUE);
Graphics2D ig2 = bi.createGraphics();
double[] xArr = toDoubleArray(Arrays.asList(Double.valueOf("121.91359648077058"), Double.valueOf("121.92293884686991")));
double[] yArr = toDoubleArray(Arrays.asList(Double.valueOf("11.995724479140792"), Double.valueOf("11.999118908426375")));
Path2D path = new Path2D.Double();
path.moveTo(xArr[0], yArr[0]);
System.out.println("x[0]=" + xArr[0] + "," + "y[0]=" + yArr[0]);
for(int i = 1; i < xArr.length; ++i) {
path.lineTo(xArr[i], yArr[i]);
System.out.println("x[" + i + "]=" + xArr[i] + "," + "y[" + i + "]" + yArr[i]);
}
path.closePath();
ig2.draw(path);
ImageIO.write(bi, "PNG", new File("polygons.png"));
It will just be a single pixel, which is 121 and 11 inside the 500,500 buffer image.
What can be done to be able to render Geolocation coordinates into an image? I really don't need the lines just plot the points in the image is sufficient, hover the Path2D
is the closest one I found since it supports double
values.