I’m trying to visualize openstreetmap data but when I go to render it to the screen, if I change the noFill and stroke it wont render anything. The weird thing is that it works perfectly with those two lines commented. Maybe you can look at it because I don’t know what it could be causing the problem
So this is my code:
import java.util.Map;
XML xml;
XML bounds;
HashMap<String, XML> nodes;
HashMap<String, XML> ways;
HashMap<String, XML> relations;
float minlat;
float minlon;
float maxlat;
float maxlon;
int x;
int y;
int scale;
void settings() {
xml = loadXML("map.osm");
bounds = xml.getChildren("bounds")[0];
nodes = new HashMap<String, XML>();
ways = new HashMap<String, XML>();
relations = new HashMap<String, XML>();
for (XML node : xml.getChildren("node")) nodes.put(node.getString("id"), node);
for (XML way : xml.getChildren("way")) ways.put(way.getString("id"), way);
for (XML relation : xml.getChildren("relations")) relations.put(relation.getString("relation"), relation);
minlat = bounds.getFloat("minlat");
minlon = bounds.getFloat("minlon");
maxlat = bounds.getFloat("maxlat");
maxlon = bounds.getFloat("maxlon");
x = 0;
y = 0;
scale = 400000;
size((int)((maxlon - minlon) * scale), (int)((maxlat - minlat) * scale), P2D);
}
void setup() {
stroke(255);
}
void draw() {
background(0);
if (mousePressed && mouseButton == LEFT) {
x += mouseX - pmouseX;
y += mouseY - pmouseY;
}
translate(-minlon * scale + x, maxlat * scale + y);
for (XML way : ways.values()) {
PShape wayShape = createShape();
wayShape.beginShape();
//wayShape.noFill();
//wayShape.stroke(255);
for (XML nd : way.getChildren("nd")) {
XML node = nodes.get(nd.getString("ref"));
float lat = node.getFloat("lat");
float lon = node.getFloat("lon");
wayShape.vertex(lon * scale, -lat * scale);
}
wayShape.endShape();
shape(wayShape);
}
println("FPS: " + frameRate);`Preformatted text`
}
This is whitout the lines commented:
This is with the stroke only (I should see the lines forming the shapes, but it’s black):
The transformations are done right and I’m not appliyng and scale sho I the the lines should be visible
This is the file:
https://mega.nz/file/8Y521ZCZ#P96Njpd6WUpUjU19XsVmm7DRSI_31ryNoMhUpaP0Dro