Class Layer
- java.lang.Object
-
- org.openstreetmap.josm.data.imagery.vectortile.mapbox.Layer
-
- All Implemented Interfaces:
Destroyable
public final class Layer extends java.lang.Object implements Destroyable
A Mapbox Vector Tile Layer- Since:
- 17862
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Layer.ValueFields<T>
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
DEFAULT_EXTENT
The default extent for a vector tileprivate static byte
DEFAULT_VERSION
private int
extent
The extent of the tile, typically 4096.private static byte
EXTENT_FIELD
private static byte
FEATURE_FIELD
private java.util.List<Feature>
featureCollection
The actual features of this layer in this tileprivate static byte
KEY_FIELD
private java.util.List<java.lang.String>
keyList
A list of unique keys.static byte
LAYER_FIELD
The field value for a layer (inProtobufRecord.getField()
)private java.lang.String
name
A unique name for the layer.private static byte
NAME_FIELD
private static byte
VALUE_FIELD
private java.util.List<java.lang.Object>
valueList
A list of unique values.private byte
version
This is technically an integer, but there are currently only two major versions (1, 2).private static byte
VERSION_FIELD
-
Constructor Summary
Constructors Constructor Description Layer(byte[] bytes)
Create a new layerLayer(java.util.Collection<ProtobufRecord> records)
Create a layer from a collection of records
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Called when the object has been destroyed.boolean
equals(java.lang.Object other)
private static java.util.Collection<ProtobufRecord>
getAllRecords(byte[] bytes)
Get all the records from a array of bytesint
getExtent()
Get the extent of the tilejava.util.Collection<Feature>
getFeatures()
Get the feature on this layerjava.util.Collection<Geometry>
getGeometry()
Get the geometry for this layerjava.lang.String
getKey(int index)
Get a specified keyjava.lang.String
getName()
Get the name of the layerjava.lang.Object
getValue(int index)
Get a specified valuebyte
getVersion()
Get the Mapbox Vector Tile version specification for this layerint
hashCode()
private void
parseValueRecord(java.io.ByteArrayOutputStream byteArrayOutputStream, ProtobufRecord protobufRecord)
-
-
-
Field Detail
-
LAYER_FIELD
public static final byte LAYER_FIELD
The field value for a layer (inProtobufRecord.getField()
)- See Also:
- Constant Field Values
-
VERSION_FIELD
private static final byte VERSION_FIELD
- See Also:
- Constant Field Values
-
NAME_FIELD
private static final byte NAME_FIELD
- See Also:
- Constant Field Values
-
FEATURE_FIELD
private static final byte FEATURE_FIELD
- See Also:
- Constant Field Values
-
KEY_FIELD
private static final byte KEY_FIELD
- See Also:
- Constant Field Values
-
VALUE_FIELD
private static final byte VALUE_FIELD
- See Also:
- Constant Field Values
-
EXTENT_FIELD
private static final byte EXTENT_FIELD
- See Also:
- Constant Field Values
-
DEFAULT_EXTENT
static final int DEFAULT_EXTENT
The default extent for a vector tile- See Also:
- Constant Field Values
-
DEFAULT_VERSION
private static final byte DEFAULT_VERSION
- See Also:
- Constant Field Values
-
version
private final byte version
This is technically an integer, but there are currently only two major versions (1, 2). Required.
-
name
private final java.lang.String name
A unique name for the layer. This must be unique on a per-tile basis. Required.
-
extent
private final int extent
The extent of the tile, typically 4096. Required.
-
keyList
private final java.util.List<java.lang.String> keyList
A list of unique keys. Order is important. Optional.
-
valueList
private final java.util.List<java.lang.Object> valueList
A list of unique values. Order is important. Optional.
-
featureCollection
private final java.util.List<Feature> featureCollection
The actual features of this layer in this tile
-
-
Constructor Detail
-
Layer
public Layer(java.util.Collection<ProtobufRecord> records) throws java.io.IOException
Create a layer from a collection of records- Parameters:
records
- The records to convert to a layer- Throws:
java.io.IOException
- - if an IO error occurs
-
Layer
public Layer(byte[] bytes) throws java.io.IOException
Create a new layer- Parameters:
bytes
- The bytes that the layer comes from- Throws:
java.io.IOException
- - if an IO error occurs
-
-
Method Detail
-
parseValueRecord
private void parseValueRecord(java.io.ByteArrayOutputStream byteArrayOutputStream, ProtobufRecord protobufRecord) throws java.io.IOException
- Throws:
java.io.IOException
-
getAllRecords
private static java.util.Collection<ProtobufRecord> getAllRecords(byte[] bytes) throws java.io.IOException
Get all the records from a array of bytes- Parameters:
bytes
- The byte information- Returns:
- All the protobuf records
- Throws:
java.io.IOException
- If there was an error reading the bytes (unlikely)
-
getExtent
public int getExtent()
Get the extent of the tile- Returns:
- The layer extent
-
getFeatures
public java.util.Collection<Feature> getFeatures()
Get the feature on this layer- Returns:
- the features
-
getGeometry
public java.util.Collection<Geometry> getGeometry()
Get the geometry for this layer- Returns:
- The geometry
-
getKey
public java.lang.String getKey(int index)
Get a specified key- Parameters:
index
- The index in the key list- Returns:
- The actual key
-
getName
public java.lang.String getName()
Get the name of the layer- Returns:
- The layer name
-
getValue
public java.lang.Object getValue(int index)
Get a specified value- Parameters:
index
- The index in the value list- Returns:
- The actual value. This can be a
String
,Boolean
,Integer
, orFloat
value.
-
getVersion
public byte getVersion()
Get the Mapbox Vector Tile version specification for this layer- Returns:
- The version of the Mapbox Vector Tile specification
-
destroy
public void destroy()
Description copied from interface:Destroyable
Called when the object has been destroyed.- Specified by:
destroy
in interfaceDestroyable
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-