Search in sources :

Example 6 with Marker

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;
}
Also used : GeoPoint(delta.games.lotro.maps.data.GeoPoint) Category(delta.games.lotro.maps.data.Category) Marker(delta.games.lotro.maps.data.Marker)

Aggregations

Marker (delta.games.lotro.maps.data.Marker)6 MarkersManager (delta.games.lotro.maps.data.MarkersManager)4 Category (delta.games.lotro.maps.data.Category)3 GeoPoint (delta.games.lotro.maps.data.GeoPoint)3 MapBundle (delta.games.lotro.maps.data.MapBundle)3 CategoriesManager (delta.games.lotro.maps.data.CategoriesManager)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Filter (delta.common.utils.collections.filters.Filter)1 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 GeoReference (delta.games.lotro.maps.data.GeoReference)1 Map (delta.games.lotro.maps.data.Map)1 MapsManager (delta.games.lotro.maps.data.MapsManager)1 CategoriesXMLWriter (delta.games.lotro.maps.data.io.xml.CategoriesXMLWriter)1 MapXMLWriter (delta.games.lotro.maps.data.io.xml.MapXMLWriter)1 MapCanvas (delta.games.lotro.maps.ui.MapCanvas)1 NavigationListener (delta.games.lotro.maps.ui.NavigationListener)1 NavigationManager (delta.games.lotro.maps.ui.NavigationManager)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1