I’m following along on the Coursera/UCSD class on Java programming. I realize this may be an Unfolding issue, but it seems that Unfolding and Processing are inextricably linked, so here I am.
I’m getting a null pointer exception when I try to convert a list of features into a list of markers using the method MapUtils.createSimpleMarkers()
.
The issue seems to be that GeoDataReader.loadData()
is not populating the list of features. I can not tell why.
This code is copied and pasted straight from class. I’m less than happy with how outdated this course is, but I’d like to finish the assignments. Thank you.
countryMarkers = MapUtils.createSimpleMarkers(countries);
Here is the larger picture:
public class LifeExpectancy extends PApplet{
UnfoldingMap map;
private String year = "2017";
private String csvPath = "data/LifeExpectancyWorldBank.csv";
private String xmlPath = "data/life_expectancy.xml";
private List<Feature> countries;
private List<Marker> countryMarkers;
private Map<String, Float> dataMap;
public void setup(){
countries = GeoDataReader.loadData(this,
"data/countries.geo.json");
countryMarkers = MapUtils.createSimpleMarkers(countries);
size(800,600, OPENGL);
map = new UnfoldingMap(this, 50, 50, 700, 500,
new Microsoft.RoadProvider());
MapUtils.createDefaultEventDispatcher(this, map);
try {
dataMap = loadLifeExpectancyData();
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
map.addMarkers(countryMarkers);
shadeMarkers();
}
public void draw(){
map.draw();
}
As a side note, the JSON file is provided with the course. I’ve opened it up to confirm that it has data in it. I’m not an expert, but everything looks good.