first .osm format import
- import osm convert it to Drawing and use it as resolved path. - Not ready , first test over lab/valbonne_oct_2020.osm
This commit is contained in:
59
java/org/artisanlogiciel/osm/convert/OsmToDrawing.java
Normal file
59
java/org/artisanlogiciel/osm/convert/OsmToDrawing.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.artisanlogiciel.osm.convert;
|
||||
|
||||
import org.artisanlogiciel.graphics.Drawing;
|
||||
import org.artisanlogiciel.graphics.DrawingLine;
|
||||
import org.artisanlogiciel.osm.Node;
|
||||
import org.artisanlogiciel.osm.NodeRef;
|
||||
import org.artisanlogiciel.osm.Way;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Take a way with resolved ref ( ie with NodeRef having non null getNode() )
|
||||
* and create a Drawing from it.
|
||||
*/
|
||||
public class OsmToDrawing {
|
||||
|
||||
double refx = 0;
|
||||
double refy = 0;
|
||||
int mulx = 1;
|
||||
int muly = 1;
|
||||
|
||||
public OsmToDrawing()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public OsmToDrawing(int mulx, int muly) {
|
||||
this.mulx = mulx;
|
||||
this.muly = muly;
|
||||
}
|
||||
|
||||
public OsmToDrawing(double refx, double refy, int mulx, int muly) {
|
||||
this.refx = refx;
|
||||
this.refy = refy;
|
||||
this.mulx = mulx;
|
||||
this.muly = muly;
|
||||
}
|
||||
|
||||
public DrawingLine getDrawingLine(Way way)
|
||||
{
|
||||
DrawingLine drawingLine = new DrawingLine();
|
||||
for (NodeRef nr : way.getNdlist())
|
||||
{
|
||||
Node node = nr.getNode();
|
||||
drawingLine.addPoint(new Point((int) ( (node.getLat() - refx)* mulx ) , (int) ( (node.getLon() - refy ) * muly) ));
|
||||
}
|
||||
return drawingLine;
|
||||
}
|
||||
|
||||
public Drawing getDrawing(List<Way> ways)
|
||||
{
|
||||
Drawing drawing = new Drawing();
|
||||
for (Way way : ways) {
|
||||
drawing.addLine(getDrawingLine(way));
|
||||
}
|
||||
return drawing;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user