Search in sources :

Example 1 with GeoPoint

use of delta.games.lotro.maps.data.GeoPoint in project lotro-tools by dmorcellet.

the class MarkersMerge method buildMarkerFootPrint.

private String buildMarkerFootPrint(Marker marker) {
    int code = marker.getCategoryCode();
    GeoPoint point = marker.getPosition();
    float latitude = point.getLatitude();
    float longitude = point.getLongitude();
    String label = marker.getLabel();
    String footPrint = label + "#" + code + "#" + latitude + "/" + longitude;
    return footPrint;
}
Also used : GeoPoint(delta.games.lotro.maps.data.GeoPoint) GeoPoint(delta.games.lotro.maps.data.GeoPoint)

Example 2 with GeoPoint

use of delta.games.lotro.maps.data.GeoPoint in project lotro-tools by dmorcellet.

the class LinkCreationInterator method doLink.

private void doLink(MapBundle bundle, int x, int y) {
    MapBundle currentMap = _canvas.getCurrentMap();
    Map map = currentMap.getMap();
    String target = bundle.getKey();
    GeoPoint hotPoint = map.getGeoReference().pixel2geo(new Dimension(x, y));
    MapLink link = new MapLink(target, hotPoint);
    map.addLink(link);
    _manager.saveMap(map.getKey());
    _canvas.repaint();
}
Also used : GeoPoint(delta.games.lotro.maps.data.GeoPoint) MapLink(delta.games.lotro.maps.data.MapLink) MapBundle(delta.games.lotro.maps.data.MapBundle) Dimension(java.awt.Dimension) Map(delta.games.lotro.maps.data.Map)

Example 3 with GeoPoint

use of delta.games.lotro.maps.data.GeoPoint in project lotro-tools by dmorcellet.

the class MapPageParser method parse.

/**
 * Parse map data.
 * @param mapBundle Storage for extracted data.
 * @param js Input file.
 */
public void parse(MapBundle mapBundle, File js) {
    List<String> lines = TextUtils.readAsLines(js);
    Float startX = null;
    Float startY = null;
    Float scale = null;
    Date date = null;
    MarkersManager markers = mapBundle.getData();
    int markerId = 1;
    for (String line : lines) {
        if (line.startsWith(STARTX_SEED)) {
            // map.StartX = -42.8;
            startX = getValue(STARTX_SEED, line);
        } else if (line.startsWith(STARTY_SEED)) {
            // map.StartY = 14.7;
            startY = getValue(STARTY_SEED, line);
        } else if (line.startsWith(SCALE2MAP_SEED)) {
            // map.ScaleToMap = 3.498879;
            scale = getValue(SCALE2MAP_SEED, line);
        } else // map.ScaleToIg = 0.285807;
        if (line.startsWith(MODIFIED_SEED)) {
            // map.Modified = "07/12/2015";
            date = getDate(MODIFIED_SEED, line);
        } else if (line.startsWith("[")) {
            Marker marker = parseItemLine(line);
            if (marker != null) {
                marker.setId(markerId);
                markerId++;
                markers.addMarker(marker);
            }
        }
    }
    Map map = mapBundle.getMap();
    if ((startX != null) && (startY != null) && (scale != null)) {
        GeoPoint start = new GeoPoint(startX.floatValue(), startY.floatValue());
        GeoReference reference = new GeoReference(start, scale.floatValue());
        map.setGeoReference(reference);
    }
    map.setLastUpdate(date);
}
Also used : GeoPoint(delta.games.lotro.maps.data.GeoPoint) Marker(delta.games.lotro.maps.data.Marker) MarkersManager(delta.games.lotro.maps.data.MarkersManager) Map(delta.games.lotro.maps.data.Map) Date(java.util.Date) GeoPoint(delta.games.lotro.maps.data.GeoPoint) GeoReference(delta.games.lotro.maps.data.GeoReference)

Example 4 with GeoPoint

use of delta.games.lotro.maps.data.GeoPoint 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

GeoPoint (delta.games.lotro.maps.data.GeoPoint)4 Map (delta.games.lotro.maps.data.Map)2 Marker (delta.games.lotro.maps.data.Marker)2 Category (delta.games.lotro.maps.data.Category)1 GeoReference (delta.games.lotro.maps.data.GeoReference)1 MapBundle (delta.games.lotro.maps.data.MapBundle)1 MapLink (delta.games.lotro.maps.data.MapLink)1 MarkersManager (delta.games.lotro.maps.data.MarkersManager)1 Dimension (java.awt.Dimension)1 Date (java.util.Date)1