| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.data.imagery.vectortile.mapbox;
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * Command integers for Mapbox Vector Tiles
|
|---|
| 6 | * @author Taylor Smock
|
|---|
| 7 | * @since 17862
|
|---|
| 8 | */
|
|---|
| 9 | public enum Command {
|
|---|
| 10 | /**
|
|---|
| 11 | * For {@link GeometryTypes#POINT}, each {@link #MoveTo} is a new point.
|
|---|
| 12 | * For {@link GeometryTypes#LINESTRING} and {@link GeometryTypes#POLYGON}, each {@link #MoveTo} is a new geometry of the same type.
|
|---|
| 13 | */
|
|---|
| 14 | MoveTo((byte) 1, (byte) 2),
|
|---|
| 15 | /**
|
|---|
| 16 | * While not explicitly prohibited for {@link GeometryTypes#POINT}, it should be ignored.
|
|---|
| 17 | * For {@link GeometryTypes#LINESTRING} and {@link GeometryTypes#POLYGON}, each {@link #LineTo} extends that geometry.
|
|---|
| 18 | */
|
|---|
| 19 | LineTo((byte) 2, (byte) 2),
|
|---|
| 20 | /**
|
|---|
| 21 | * This is only explicitly valid for {@link GeometryTypes#POLYGON}. It closes the {@link GeometryTypes#POLYGON}.
|
|---|
| 22 | */
|
|---|
| 23 | ClosePath((byte) 7, (byte) 0);
|
|---|
| 24 |
|
|---|
| 25 | private static final Command[] CACHED_VALUES = Command.values();
|
|---|
| 26 | private final byte id;
|
|---|
| 27 | private final byte parameters;
|
|---|
| 28 |
|
|---|
| 29 | Command(byte id, byte parameters) {
|
|---|
| 30 | this.id = id;
|
|---|
| 31 | this.parameters = parameters;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Get the command id
|
|---|
| 36 | * @return The id
|
|---|
| 37 | */
|
|---|
| 38 | public byte getId() {
|
|---|
| 39 | return this.id;
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | /**
|
|---|
| 43 | * Get the number of parameters
|
|---|
| 44 | * @return The number of parameters
|
|---|
| 45 | */
|
|---|
| 46 | public byte getParameterNumber() {
|
|---|
| 47 | return this.parameters;
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | /**
|
|---|
| 51 | * Get a pre-calculated array of all {@link Command} values.
|
|---|
| 52 | * @return An array of values, meant as a drop-in replacement for {@link Command#values()}
|
|---|
| 53 | * <i>where the array is not modified</i>! This can significantly reduce allocations, as there is no defensive
|
|---|
| 54 | * array copy.
|
|---|
| 55 | */
|
|---|
| 56 | static Command[] getAllValues() {
|
|---|
| 57 | return CACHED_VALUES;
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|