All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.wirelabs.jmaps.map.MapObject Maven / Gradle / Ivy

The newest version!
package net.wirelabs.jmaps.map;

import lombok.Getter;
import lombok.Setter;
import net.wirelabs.jmaps.map.layer.Layer;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

@Getter
public class MapObject {

    @Setter private String mapName = "[no name defined]";
    @Setter private String mapCopyrightAttribution = "[no attribution in definition]";
    private final List layers = new CopyOnWriteArrayList<>();

    public Layer getBaseLayer() {
        return layers.get(0);
    }

    public boolean layersPresent() {
        return !layers.isEmpty();
    }

    public List getEnabledLayers() {
        return layers.stream()
                .filter(Layer::isEnabled)
                .collect(Collectors.toList());
    }

    public int getMaxZoom() {
        return layers.stream()
                .map(layer -> layer.getMaxZoom() - layer.getZoomOffset())
                .mapToInt(v -> v)
                .min().orElse(0);
    }

    public int getMinZoom() {
        return layers
                .stream()
                .map(Layer::getMinZoom)
                .mapToInt(val -> val)
                .max().orElse(0);
    }

    public boolean isMultilayer() {
        return layers.size() > 1;
    }

    public void addLayer(Layer layer) {
        layers.add(layer);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy