use of delta.games.lotro.maps.data.Marker in project lotro-tools by dmorcellet.
the class MapPageParser method parseItemLine.
private Marker parseItemLine(String line) {
// [-77.4,-24.6,{en:"Auctioneer",de:"TBD",fr:"TBD"},13,"Auctioneer"],
line = line.trim();
if (line.endsWith(","))
line = line.substring(0, line.length() - 1);
line = TextTools.findBetween(line, "[", "]");
Marker marker = new Marker();
String part1 = findBefore(line, "{");
String labels = TextTools.findBetween(line, "{", "}");
String part3 = TextTools.findAfter(line, "}");
ParsingUtils.parseLabels(marker.getLabels(), "{" + labels + "}");
Float latitude = null;
Float longitude = null;
String[] posItems = part1.split(",");
if (posItems.length == 2) {
latitude = NumericTools.parseFloat(posItems[0]);
longitude = NumericTools.parseFloat(posItems[1]);
}
Integer categoryCode = null;
String[] categoryItems = part3.split(",");
if (categoryItems.length >= 3) {
categoryCode = NumericTools.parseInteger(categoryItems[1]);
}
String comment = null;
if (categoryItems.length >= 4) {
comment = TextTools.findBetween(categoryItems[3], "\"", "\"");
}
marker.setComment(comment);
if ((latitude != null) && (longitude != null) && (categoryCode != null)) {
GeoPoint position = new GeoPoint(longitude.floatValue(), latitude.floatValue());
marker.setPosition(position);
Category category = _categories.getByCode(categoryCode.intValue());
if (category == null) {
_logger.warn("Category not found: " + categoryCode);
}
marker.setCategory(category);
} else {
_logger.warn("Bad line: " + line);
}
return marker;
}
Aggregations