diff --git a/README.md b/README.md index 0594572..88dd854 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # seamless-census -Import US Census data into a seamless storage environment. +Download US Census data for use in a seamless storage environment. + +Java main classes for loading/extracting these data have been moved to [r5](https://github.com/conveyal/r5) and a gradle (as opposed to maven) build system. ## Usage @@ -18,17 +20,16 @@ The command below, for instance, would download data for the greater Washington, ### Load data -Use the same temporary directory -you used above. If you omit the s3 bucket name, it will place the tiles in the `tiles` directory in the temporary directory. +Load data using a built r5 .jar (e.g. v6.2.jar). Use the same data directory you used above. If you omit the s3 bucket name, it will place the tiles in the `tiles` directory in the temporary directory. - JAVA_OPTS=-Xmx[several]G mvn exec:java -Dexec.mainClass="com.conveyal.data.census.CensusLoader" -Dexec.args="temporary_dir s3_bucket_name" + java -Xmx30G -cp v6.2.jar com.conveyal.data.census.CensusLoader data lodes-data-xxxx ### Extract data Now for the fun part. The following command will extract the data stored in the s3 bucket specified, using the bounding box specified, to the geobuf file out.pbf. - JAVA_OPTS=-Xmx[several]G mvn exec:java -Dexec.mainClass="com.conveyal.data.census.CensusExtractor" -Dexec.args="s3://bucket_name n e s w out.pbf" + java -Xmx30G -cp v6.2.jar com.conveyal.data.census.CensusExtractor s3://lodes-data-xxxx n e s w out.pbf" ## Data storage @@ -45,7 +46,9 @@ We have already loaded LODES data from 2013, 2014, 2015, and 2017 in the S3 buck These buckets and their contents are publicly readable and requester-pays (i.e. accessing them will incur fees on your AWS account). The 2013 data lack Massachusetts, and uses 2011 data for Kansas, due to data availability. The 2014 and 2015 data do not have these problems. -The 2017 data exclude federal employees and use 2016 data for Alaska and South Dakota. See LODES Technical Documentation for details. +The 2017 data exclude federal employees and use 2016 data for Alaska and South Dakota (see [LODES Technical Documentation 7.4](https://lehd.ces.census.gov/data/lodes/LODES7/LODESTechDoc7.4.pdf)) +The 2018 data use 2016 data for Alaska WAC. (see [LODES Technical Documentation 7.5](https://lehd.ces.census.gov/data/lodes/LODES7/LODESTechDoc7.5.pdf)) + ## Use in Conveyal Analysis diff --git a/downloadData.py b/downloadData.py index 8ea6412..1ee869f 100644 --- a/downloadData.py +++ b/downloadData.py @@ -133,12 +133,12 @@ def retrieve(url, path): # figure out the year of the latest available data # Most states have 2015 data available # see http://lehd.ces.census.gov/data/lodes/LODES7/LODESTechDoc7.4.pdf, page 2f - year = 2017 + year = 2018 # Alaska and South Dakota do not have LODES2017 data available, so use 2016 - if state == 'AK' or state == 'SD': + if state == 'AK': year = 2016 - elif state == 'PR' or state == 'VI': + elif state == 'PR' or state == 'VI' or state == 'AS': print('{0} does not have LODES data available'.format(state)) year = 0 diff --git a/src/main/java/com/conveyal/data/census/CensusExtractor.java b/src/main/java/com/conveyal/data/census/CensusExtractor.java deleted file mode 100644 index 01c2b4a..0000000 --- a/src/main/java/com/conveyal/data/census/CensusExtractor.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.conveyal.data.census; - -import com.conveyal.data.geobuf.GeobufEncoder; -import com.conveyal.data.geobuf.GeobufFeature; -import com.conveyal.geojson.GeoJsonModule; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.GeometryCollection; -import org.locationtech.jts.geom.GeometryFactory; -import org.locationtech.jts.geom.Polygon; - -import java.io.*; -import java.util.List; -import java.util.Map; - -/** - * Extract Census data from a seamless datastore. - */ -public class CensusExtractor { - /** - * The precision to use for output files. - * Set above 6 at your own risk; higher precision files work fine with the reference implementation and with geobuf-java, - * but break with pygeobuf (see https://github.com/mapbox/pygeobuf/issues/21) - */ - private static final int PRECISION = 6; - - public static void main (String... args) throws IOException { - if (args.length < 3 || args.length > 6) { - System.err.println("usage: CensusExtractor (s3://bucket|data_dir) n e s w [outfile.json]"); - System.err.println(" or: CensusExtractor (s3://bucket|data_dir) boundary.geojson [outfile.json]"); - return; - } - - SeamlessSource source; - if (!args[0].startsWith("s3://")) - source = new FileSeamlessSource(args[0]); - else - source = new S3SeamlessSource(args[0].substring(5)); - - long start = System.currentTimeMillis(); - - Map features; - - if (args.length >= 4) { - features = source.extract(Double.parseDouble(args[1]), - Double.parseDouble(args[2]), - Double.parseDouble(args[3]), - Double.parseDouble(args[4]), - false - ); - } - else { - // read geojson boundary - ObjectMapper om = new ObjectMapper(); - om.registerModule(new GeoJsonModule()); - FileInputStream fis = new FileInputStream(new File(args[1])); - FeatureCollection fc = om.readValue(fis, FeatureCollection.class); - fis.close(); - - features = source.extract(fc.features.get(0).geometry, false); - } - - OutputStream out; - - long completeTime = System.currentTimeMillis() - start; - System.err.println("Read " + features.size() + " features in " + completeTime + "msec"); - - if (args.length == 6) - out = new FileOutputStream(new File(args[5])); - else if (args.length == 3) - out = new FileOutputStream(new File(args[2])); - else - out = System.out; - - GeobufEncoder encoder = new GeobufEncoder(out, PRECISION); - encoder.writeFeatureCollection(features.values()); - encoder.close(); - - if (out instanceof FileOutputStream) - out.close(); - } - - // rudimentary geojson classes to deserialize feature collection - - public static class FeatureCollection { - public String type; - public Map crs; - public List features; - } - - public static class Feature { - public String type; - public Map properties; - public Geometry geometry; - } -} diff --git a/src/main/java/com/conveyal/data/census/CensusLoader.java b/src/main/java/com/conveyal/data/census/CensusLoader.java deleted file mode 100644 index 792a382..0000000 --- a/src/main/java/com/conveyal/data/census/CensusLoader.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.conveyal.data.census; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.stream.Stream; - -/** - * Import data from the US Census into a seamless store in S3 or on disk. - */ -public class CensusLoader { - protected static final Logger LOG = LoggerFactory.getLogger(CensusLoader.class); - - public static void main (String... args) throws Exception { - File indir = new File(args[0]); - File tiger = new File(indir, "tiger"); - - ShapeDataStore store = new ShapeDataStore(); - - // load up the tiger files in parallel - LOG.info("Loading TIGER (geometry)"); - Stream.of(tiger.listFiles()) - .filter(f -> f.getName().endsWith(".shp")) - .forEach(f -> { - LOG.info("Loading file {}", f); - TigerLineSource src = new TigerLineSource(f); - try { - src.load(store); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - - LOG.info("TIGER done"); - - LOG.info("Loading LODES workforce data"); - File workforce = new File(indir, "workforce"); - Stream.of(workforce.listFiles()) - .filter(f -> f.getName().endsWith(".csv.gz")) - .forEach(f -> { - LOG.info("Loading file {}", f); - try { - new LodesSource(f, LodesSource.LodesType.RESIDENCE).load(store); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - LOG.info("Workforce done"); - - LOG.info("Loading LODES jobs data"); - File jobs = new File(indir, "jobs"); - Stream.of(jobs.listFiles()) - .filter(f -> f.getName().endsWith(".csv.gz")) - .forEach(f -> { - LOG.info("Loading file {}", f); - try { - new LodesSource(f, LodesSource.LodesType.WORKPLACE).load(store); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - LOG.info("Jobs done"); - - if (args.length == 1) - store.writeTiles(new File(indir, "tiles")); - else - // write to s3 - store.writeTilesToS3(args[1]); - - store.close(); - } -} diff --git a/src/main/java/com/conveyal/data/census/FileSeamlessSource.java b/src/main/java/com/conveyal/data/census/FileSeamlessSource.java deleted file mode 100644 index c8a17ca..0000000 --- a/src/main/java/com/conveyal/data/census/FileSeamlessSource.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.conveyal.data.census; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Seamless source for the file system. - */ -public class FileSeamlessSource extends SeamlessSource { - private File directory; - - public FileSeamlessSource(String path) { - this.directory = new File(path); - } - - @Override protected InputStream getInputStream(int x, int y) throws IOException { - File dir = new File(directory, x + ""); - File file = new File(dir, y + ".pbf.gz"); - - if (!file.exists()) - return null; - - return new FileInputStream(file); - } -} diff --git a/src/main/java/com/conveyal/data/census/LodesSource.java b/src/main/java/com/conveyal/data/census/LodesSource.java deleted file mode 100644 index b15d359..0000000 --- a/src/main/java/com/conveyal/data/census/LodesSource.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.conveyal.data.census; - -import com.conveyal.data.geobuf.GeobufFeature; -import com.csvreader.CsvReader; - -import java.io.*; -import java.util.HashMap; -import java.util.Map; -import java.util.zip.GZIPInputStream; - -/** - * Data source for LODES data. - */ -public class LodesSource { - private File input; - private LodesType type; - - public LodesSource(File input, LodesType type) { - this.input = input; - this.type = type; - } - - public void load(ShapeDataStore store) throws Exception { - InputStream csv = new GZIPInputStream(new BufferedInputStream(new FileInputStream(input))); - CsvReader reader = new CsvReader(new InputStreamReader(csv)); - - // rename the columns to something useful - //http://lehd.ces.census.gov/data/lodes/LODES7/LODESTechDoc7.1.pdf#page=7&zoom=auto,-266,580 - Map colNames = new HashMap<>(); - colNames.put("C000", "total"); - - colNames.put("CA01", "age 29 or younger"); - colNames.put("CA02", "age 30 to 54"); - colNames.put("CA03", "age 55 or older"); - - colNames.put("CE01", "with earnings $1250 per month or less"); - colNames.put("CE02", "with earnings $1251 - $3333 per month"); - colNames.put("CE03", "with earnings greater than $3333 per month"); - - colNames.put("CNS01", "in agriculture, forestry, fishing and hunting"); - colNames.put("CNS02", "in mining, quarrying, and oil and gas extraction"); - colNames.put("CNS03", "in utilities"); - colNames.put("CNS04", "in construction"); - colNames.put("CNS05", "in manufacturing"); - colNames.put("CNS06", "in wholesale trade"); - colNames.put("CNS07", "in retail trade"); - colNames.put("CNS08", "in transportation and warehousing"); - colNames.put("CNS09", "in information"); - colNames.put("CNS10", "in finance and insurance"); - colNames.put("CNS11", "in real estate"); - colNames.put("CNS12", "in professional, scientific and technical services"); - colNames.put("CNS13", "in management"); - colNames.put("CNS14", "in administration, support, and waste management"); - colNames.put("CNS15", "in educational services"); - colNames.put("CNS16", "in healthcare and social assistance"); - colNames.put("CNS17", "in arts, entertainment and recreation"); - colNames.put("CNS18", "in accommodation and food services"); - colNames.put("CNS19", "in other services, except public administration"); - colNames.put("CNS20", "in public administration"); - - colNames.put("CR01", "with race White alone"); - colNames.put("CR02", "with race Black or African American alone"); - colNames.put("CR03", "with race American Indian or Alaska Native alone"); - colNames.put("CR04", "with race Asian alone"); - colNames.put("CR05", "with race Native Hawaiian or Other Pacific Islander alone"); - colNames.put("CR07", "with two or more racial groups"); - - colNames.put("CT01", "not Hispanic or Latino"); - colNames.put("CT02", "Hispanic or Latino"); - - colNames.put("CD01", "with less than high school education"); - colNames.put("CD02", "with high school education, no college"); - colNames.put("CD03", "with some college education or Associate degree"); - colNames.put("CD04", "with Bachelor's degree or higher"); - colNames.put("CS01", "male"); - colNames.put("CS02", "female"); - - // only in workplace characteristics - colNames.put("CFA01", "at firms aged 0-1 years"); - colNames.put("CFA02", "at firms aged 2-3 years"); - colNames.put("CFA03", "at firms aged 4-5 years"); - colNames.put("CFA04", "at firms aged 6-10 years"); - colNames.put("CFA05", "at firms aged 11 or more years"); - - colNames.put("CFS01", "at firms with 0-19 employees"); - colNames.put("CFS02", "at firms with 20-49 employees"); - colNames.put("CFS03", "at firms with 50-249 employees"); - colNames.put("CFS04", "at firms with 250-499 employees"); - colNames.put("CFS05", "at firms with 500 or more employees"); - colNames.put("createdate", "Data creation date"); - - reader.readHeaders(); - String[] headers = reader.getHeaders(); - - // read the file - while (reader.readRecord()) { - long id = Long.parseLong(reader.get(type == LodesType.WORKPLACE ? "w_geocode" : "h_geocode")); - GeobufFeature feat = store.get(id); - - String[] line = reader.getValues(); - for (int i = 0; i < line.length; i++) { - String col = headers[i]; - - if (!colNames.containsKey(col)) - continue; - - String colName; - - if (type == LodesType.WORKPLACE) { - if (col.startsWith("CR") || col.startsWith("CD") || col.startsWith("CA")) - colName = "Jobs employing workers " + colNames.get(col); - else if (col.startsWith("CS")) - colName = "Jobs employing " + colNames.get(col) + "s"; - else if (col.startsWith("CT")) - colName = "Jobs employing " + colNames.get(col) + " workers"; - else - colName = "Jobs " + colNames.get(col); - } - else if (type == LodesType.RESIDENCE) { - if (col.startsWith("CT") || col.startsWith("CS")) - colName = "Workers, " + colNames.get(col); - else - colName = "Workers " + colNames.get(col); - } - else { - throw new IllegalArgumentException("Invalid LODES type"); - } - - feat.properties.put(colName, Integer.parseInt(line[i])); - } - - store.put(feat); - } - - reader.close(); - } - - /** supported lodes types are workplace area characteristics and residence area characteristics */ - public static enum LodesType { - WORKPLACE, RESIDENCE - } -} diff --git a/src/main/java/com/conveyal/data/census/S3SeamlessSource.java b/src/main/java/com/conveyal/data/census/S3SeamlessSource.java deleted file mode 100644 index d9e8010..0000000 --- a/src/main/java/com/conveyal/data/census/S3SeamlessSource.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.conveyal.data.census; - -import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3Client; -import com.amazonaws.services.s3.AmazonS3ClientBuilder; -import com.amazonaws.services.s3.model.AmazonS3Exception; -import com.amazonaws.services.s3.model.GetObjectRequest; - -import java.io.IOException; -import java.io.InputStream; - -/** - * A seamless data source based on storage in Amazon S3. - */ -public class S3SeamlessSource extends SeamlessSource { - private static AmazonS3 s3; - - public final String region; - public final String bucketName; - - public S3SeamlessSource(String bucketName) { - this.region = null; - this.bucketName = bucketName; - this.s3 = AmazonS3ClientBuilder.defaultClient(); - } - - public S3SeamlessSource(String region, String bucketName) { - this.region = region; - this.bucketName = bucketName; - this.s3 = AmazonS3ClientBuilder.standard() - .withRegion(region) - .build(); - } - - @Override - protected InputStream getInputStream(int x, int y) throws IOException { - try { - GetObjectRequest req = new GetObjectRequest(bucketName, String.format("%d/%d.pbf.gz", x, y)); - // the LODES bucket is requester-pays. - req.setRequesterPays(true); - return s3.getObject(req).getObjectContent(); - } catch (AmazonS3Exception e) { - // there is no data in this tile - if ("NoSuchKey".equals(e.getErrorCode())) - return null; - else - // re-throw, something else is amiss - throw e; - } - } -} diff --git a/src/main/java/com/conveyal/data/census/SeamlessSource.java b/src/main/java/com/conveyal/data/census/SeamlessSource.java deleted file mode 100644 index 134f7df..0000000 --- a/src/main/java/com/conveyal/data/census/SeamlessSource.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.conveyal.data.census; - -import com.conveyal.data.geobuf.GeobufDecoder; -import com.conveyal.data.geobuf.GeobufFeature; -import org.locationtech.jts.geom.*; -import org.locationtech.jts.geom.prep.PreparedPolygon; -import org.locationtech.jts.util.GeometricShapeFactory; -import org.mapdb.DBMaker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.zip.GZIPInputStream; - -import static com.conveyal.data.census.ShapeDataStore.lat2tile; -import static com.conveyal.data.census.ShapeDataStore.lon2tile; - -/** - * A tile source for seamless Census extracts - */ -public abstract class SeamlessSource { - // convenience - private static final int ZOOM_LEVEL = ShapeDataStore.ZOOM_LEVEL; - - protected static final Logger LOG = LoggerFactory.getLogger(SeamlessSource.class); - - private static final GeometryFactory geometryFactory = new GeometryFactory(); - - /** Extract features by bounding box */ - public Map extract(double north, double east, double south, double west, boolean onDisk) throws - IOException { - GeometricShapeFactory factory = new GeometricShapeFactory(geometryFactory); - factory.setCentre(new Coordinate((east + west) / 2, (north + south) / 2)); - factory.setWidth(east - west); - factory.setHeight(north - south); - Polygon rect = factory.createRectangle(); - return extract(rect, onDisk); - } - - /** Extract features by arbitrary polygons */ - public Map extract(Geometry bounds, boolean onDisk) throws IOException { - Map ret; - - if (onDisk) - ret = DBMaker.tempTreeMap(); - else - ret = new HashMap<>(); - - Envelope env = bounds.getEnvelopeInternal(); - double west = env.getMinX(), east = env.getMaxX(), north = env.getMaxY(), south = env.getMinY(); - - // TODO: use prepared polygons - - // figure out how many tiles we're requesting - int minX = lon2tile(west, ZOOM_LEVEL), maxX = lon2tile(east, ZOOM_LEVEL), - minY = lat2tile(north, ZOOM_LEVEL), maxY = lat2tile(south, ZOOM_LEVEL); - - int tcount = (maxX - minX + 1) * (maxY - minY + 1); - - LOG.info("Requesting {} tiles", tcount); - - int fcount = 0; - - // read all the relevant tiles - for (int x = minX; x <= maxX; x++) { - for (int y = minY; y <= maxY; y++) { - InputStream is = getInputStream(x, y); - - if (is == null) - // no data in this tile - continue; - - // decoder closes input stream as soon as it has read the tile - GeobufDecoder decoder = new GeobufDecoder(new GZIPInputStream(new BufferedInputStream(is))); - - while (decoder.hasNext()) { - GeobufFeature f = decoder.next(); - // blocks are duplicated at the edges of tiles, no need to import twice - if (ret.containsKey(f.numericId)) - continue; - - if (!bounds.disjoint(f.geometry)) { - ret.put(f.numericId, f); - fcount++; - - if (fcount % 1000 == 0) - LOG.info("Read {} features", fcount); - } - } - } - } - - return ret; - } - - /** get an input stream for the given tile */ - protected abstract InputStream getInputStream(int x, int y) throws IOException; -} diff --git a/src/main/java/com/conveyal/data/census/ShapeDataStore.java b/src/main/java/com/conveyal/data/census/ShapeDataStore.java deleted file mode 100644 index 6d91681..0000000 --- a/src/main/java/com/conveyal/data/census/ShapeDataStore.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.conveyal.data.census; - -import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3ClientBuilder; -import com.amazonaws.services.s3.model.ObjectMetadata; -import com.conveyal.data.geobuf.GeobufEncoder; -import com.conveyal.data.geobuf.GeobufFeature; -import org.locationtech.jts.geom.Envelope; -import org.mapdb.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.NavigableSet; -import java.util.concurrent.*; -import java.util.function.BiFunction; -import java.util.zip.GZIPOutputStream; - -/** - * Store geographic data by ID, with index by zoom-11 tile. - */ -public class ShapeDataStore { - public static final int ZOOM_LEVEL = 11; - - private static final Logger LOG = LoggerFactory.getLogger(ShapeDataStore.class); - - /** number of decimal places of precision to store */ - public static final int PRECISION = 12; - - private DB db; - - /** - * set of Object[] { int[] { x, y }, Feature } for features at zoom 11 - */ - private NavigableSet tiles; - - /** - * Map from geoid to feature - */ - private BTreeMap features; - - public ShapeDataStore() { - db = DBMaker.tempFileDB().deleteFilesAfterClose().asyncWriteEnable() - .transactionDisable() - .fileMmapEnable() - .asyncWriteEnable() - .asyncWriteFlushDelay(1000) - .executorEnable() - .asyncWriteQueueSize(10000) - // start with 1GB - .allocateStartSize(1024 * 1024 * 1024) - // and bump by 512MB - .allocateIncrement(512 * 1024 * 1024) - .make(); - - features = db.treeMapCreate("features") - .keySerializer(BTreeKeySerializer.LONG) - .valueSerializer(new GeobufEncoder.GeobufFeatureSerializer(12)) - .counterEnable() - .make(); - - tiles = db.treeSetCreate("tiles") - .serializer(BTreeKeySerializer.ARRAY3) - .make(); - - // bind the map by tile - features.modificationListenerAdd((id, feat0, feat1) -> { - if (feat0 != null) - // updates never change geometry, and there are no deletes - return; - - // figure out which z11 tiles this is part of - Envelope e = feat1.geometry.getEnvelopeInternal(); - for (int x = lon2tile(e.getMinX(), ZOOM_LEVEL); x <= lon2tile(e.getMaxX(), ZOOM_LEVEL); x++) { - for (int y = lat2tile(e.getMaxY(), ZOOM_LEVEL); y <= lat2tile(e.getMinY(), ZOOM_LEVEL); y++) { - tiles.add(new Object[]{x, y, feat1.numericId}); - } - } - }); - } - - public void add(GeobufFeature feature) { - if (this.features.containsKey(feature.numericId)) - throw new IllegalArgumentException("ID " + feature.numericId + " already present in store"); - this.features.put(feature.numericId, feature); - - if (this.features.size() % 10000 == 0) - LOG.info("Loaded {} features", this.features.size()); - } - - /** Get the longitude of a particular tile */ - public static int lon2tile (double lon, int zoom) { - // recenter - lon += 180; - - // scale - return (int) (lon * Math.pow(2, zoom) / 360); - } - - public void close () { - db.close(); - } - - /** Get the latitude of a particular tile */ - public static int lat2tile (double lat, int zoom) { - // http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames - lat = Math.toRadians(lat); - lat = Math.log(Math.tan(lat) + 1 / Math.cos(lat)); - - return (int) ((1 - lat / Math.PI) / 2 * Math.pow(2, zoom)); - } - - /** Write GeoBuf tiles to a directory */ - public void writeTiles (File file) throws IOException { - writeTilesInternal((x, y) -> { - // write out the features - File dir = new File(file, "" + x); - File out = new File(dir, y + ".pbf.gz"); - dir.mkdirs(); - return new FileOutputStream(out); - }); - } - - /** Write GeoBuf tiles to S3 */ - public void writeTilesToS3 (String bucketName) throws IOException { - // set up an upload thread - ExecutorService executor = Executors.newSingleThreadExecutor(); - - // initialize an S3 client - AmazonS3 s3 = - AmazonS3ClientBuilder.standard().build(); - try { - writeTilesInternal((x, y) -> { - PipedInputStream is = new PipedInputStream(); - PipedOutputStream os = new PipedOutputStream(is); - ObjectMetadata metadata = new ObjectMetadata(); - metadata.setContentType("application/gzip"); - - // perform the upload in its own thread so it doesn't deadlock - executor.execute(() -> s3.putObject(bucketName, String.format("%d/%d.pbf.gz", x, y), is, metadata)); - return os; - }); - } finally { - // allow the JVM to exit - executor.shutdown(); - try { - executor.awaitTermination(1, TimeUnit.HOURS); - } catch (InterruptedException e) { - LOG.error("Interrupted while waiting for S3 uploads to finish"); - } - } - } - - /** - * generic write tiles function, calls function with x and y indices to get an output stream, which it will close itself. - * The Internal suffix is because lambdas in java get confused with overloaded functions - */ - private void writeTilesInternal(TileOutputStreamProducer outputStreamForTile) throws IOException { - int lastx = -1, lasty = -1, tileCount = 0; - - List featuresThisTile = new ArrayList<>(); - - for (Object[] val : tiles) { - int x = (Integer) val[0]; - int y = (Integer) val[1]; - long id = (Long) val[2]; - - if (x != lastx || y != lasty) { - if (!featuresThisTile.isEmpty()) { - LOG.debug("x: {}, y: {}, {} features", lastx, lasty, featuresThisTile.size()); - GeobufEncoder enc = new GeobufEncoder(new GZIPOutputStream(new BufferedOutputStream(outputStreamForTile.apply(lastx, lasty))), PRECISION); - enc.writeFeatureCollection(featuresThisTile); - enc.close(); - featuresThisTile.clear(); - - tileCount++; - } - } - - featuresThisTile.add(features.get(id)); - - lastx = x; - lasty = y; - } - - LOG.info("Wrote {} tiles", tileCount); - } - - /** get a feature */ - public GeobufFeature get(long id) { - // protective copy, don't get entangled in mapdb async serialization. - return features.get(id).clone(); - } - - /** put a feature that already exists */ - public void put (GeobufFeature feat) { - if (!features.containsKey(feat.numericId)) - throw new IllegalArgumentException("Feature does not exist in database!"); - - features.put(feat.numericId, feat); - } - - @FunctionalInterface - private interface TileOutputStreamProducer { - public OutputStream apply (int x, int y) throws IOException; - } -} diff --git a/src/main/java/com/conveyal/data/census/TigerLineSource.java b/src/main/java/com/conveyal/data/census/TigerLineSource.java deleted file mode 100644 index 21a5834..0000000 --- a/src/main/java/com/conveyal/data/census/TigerLineSource.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.conveyal.data.census; - -import com.conveyal.data.geobuf.GeobufFeature; -import org.geotools.data.FileDataStore; -import org.geotools.data.FileDataStoreFinder; -import org.geotools.data.Query; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.referencing.CRS; - -import java.io.File; -import java.util.HashMap; - -/** - * Reads TIGER/Line data into a MapDB. - */ -public class TigerLineSource { - private File shapefile; - - public TigerLineSource (File shapefile) { - this.shapefile = shapefile; - } - - public void load (ShapeDataStore store) throws Exception { - FileDataStore fds = FileDataStoreFinder.getDataStore(shapefile); - SimpleFeatureSource src = fds.getFeatureSource(); - - Query q = new Query(); - q.setCoordinateSystem(src.getInfo().getCRS()); - q.setCoordinateSystemReproject(CRS.decode("EPSG:4326", true)); - SimpleFeatureCollection sfc = src.getFeatures(q); - - for (SimpleFeatureIterator it = sfc.features(); it.hasNext();) { - GeobufFeature feat = new GeobufFeature(it.next()); - feat.id = null; - feat.numericId = Long.parseLong((String) feat.properties.get("GEOID10")); - feat.properties = new HashMap<>(); - store.add(feat); - } - } -} diff --git a/src/main/java/geobuf/Geobuf.java b/src/main/java/geobuf/Geobuf.java deleted file mode 100644 index 7e1c316..0000000 --- a/src/main/java/geobuf/Geobuf.java +++ /dev/null @@ -1,6020 +0,0 @@ -package geobuf; - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: geobuf.proto - -public final class Geobuf { - private Geobuf() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - public interface DataOrBuilder extends - // @@protoc_insertion_point(interface_extends:Data) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - com.google.protobuf.ProtocolStringList - getKeysList(); - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - int getKeysCount(); - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - java.lang.String getKeys(int index); - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - com.google.protobuf.ByteString - getKeysBytes(int index); - - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-     * max coordinate dimensions
-     * 
- */ - boolean hasDimensions(); - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-     * max coordinate dimensions
-     * 
- */ - int getDimensions(); - - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-     * number of digits after decimal point for coordinates
-     * 
- */ - boolean hasPrecision(); - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-     * number of digits after decimal point for coordinates
-     * 
- */ - int getPrecision(); - - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - boolean hasFeatureCollection(); - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - Geobuf.Data.FeatureCollection getFeatureCollection(); - - /** - * optional .Data.Feature feature = 5; - */ - boolean hasFeature(); - /** - * optional .Data.Feature feature = 5; - */ - Geobuf.Data.Feature getFeature(); - - /** - * optional .Data.Geometry geometry = 6; - */ - boolean hasGeometry(); - /** - * optional .Data.Geometry geometry = 6; - */ - Geobuf.Data.Geometry getGeometry(); - } - /** - * Protobuf type {@code Data} - */ - public static final class Data extends - com.google.protobuf.GeneratedMessageLite implements - // @@protoc_insertion_point(message_implements:Data) - DataOrBuilder { - // Use Data.newBuilder() to construct. - private Data(com.google.protobuf.GeneratedMessageLite.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Data(boolean noInit) { this.unknownFields = com.google.protobuf.ByteString.EMPTY;} - - private static final Data defaultInstance; - public static Data getDefaultInstance() { - return defaultInstance; - } - - public Data getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.ByteString unknownFields; - private Data( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.ByteString.Output unknownFieldsOutput = - com.google.protobuf.ByteString.newOutput(); - com.google.protobuf.CodedOutputStream unknownFieldsCodedOutput = - com.google.protobuf.CodedOutputStream.newInstance( - unknownFieldsOutput); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFieldsCodedOutput, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - keys_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000001; - } - keys_.add(bs); - break; - } - case 16: { - bitField0_ |= 0x00000001; - dimensions_ = input.readUInt32(); - break; - } - case 24: { - bitField0_ |= 0x00000002; - precision_ = input.readUInt32(); - break; - } - case 34: { - Geobuf.Data.FeatureCollection.Builder subBuilder = null; - if (dataTypeCase_ == 4) { - subBuilder = ((Geobuf.Data.FeatureCollection) dataType_).toBuilder(); - } - dataType_ = input.readMessage(Geobuf.Data.FeatureCollection.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((Geobuf.Data.FeatureCollection) dataType_); - dataType_ = subBuilder.buildPartial(); - } - dataTypeCase_ = 4; - break; - } - case 42: { - Geobuf.Data.Feature.Builder subBuilder = null; - if (dataTypeCase_ == 5) { - subBuilder = ((Geobuf.Data.Feature) dataType_).toBuilder(); - } - dataType_ = input.readMessage(Geobuf.Data.Feature.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((Geobuf.Data.Feature) dataType_); - dataType_ = subBuilder.buildPartial(); - } - dataTypeCase_ = 5; - break; - } - case 50: { - Geobuf.Data.Geometry.Builder subBuilder = null; - if (dataTypeCase_ == 6) { - subBuilder = ((Geobuf.Data.Geometry) dataType_).toBuilder(); - } - dataType_ = input.readMessage(Geobuf.Data.Geometry.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom((Geobuf.Data.Geometry) dataType_); - dataType_ = subBuilder.buildPartial(); - } - dataTypeCase_ = 6; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - keys_ = keys_.getUnmodifiableView(); - } - try { - unknownFieldsCodedOutput.flush(); - } catch (java.io.IOException e) { - // Should not happen - } finally { - unknownFields = unknownFieldsOutput.toByteString(); - } - makeExtensionsImmutable(); - } - } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Data parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Data(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface FeatureOrBuilder extends - // @@protoc_insertion_point(interface_extends:Data.Feature) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * required .Data.Geometry geometry = 1; - */ - boolean hasGeometry(); - /** - * required .Data.Geometry geometry = 1; - */ - Geobuf.Data.Geometry getGeometry(); - - /** - * optional string id = 11; - */ - boolean hasId(); - /** - * optional string id = 11; - */ - java.lang.String getId(); - /** - * optional string id = 11; - */ - com.google.protobuf.ByteString - getIdBytes(); - - /** - * optional sint64 int_id = 12; - */ - boolean hasIntId(); - /** - * optional sint64 int_id = 12; - */ - long getIntId(); - - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - java.util.List - getValuesList(); - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - Geobuf.Data.Value getValues(int index); - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - int getValuesCount(); - - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - java.util.List getPropertiesList(); - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - int getPropertiesCount(); - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - int getProperties(int index); - - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - java.util.List getCustomPropertiesList(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - int getCustomPropertiesCount(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - int getCustomProperties(int index); - } - /** - * Protobuf type {@code Data.Feature} - */ - public static final class Feature extends - com.google.protobuf.GeneratedMessageLite implements - // @@protoc_insertion_point(message_implements:Data.Feature) - FeatureOrBuilder { - // Use Feature.newBuilder() to construct. - private Feature(com.google.protobuf.GeneratedMessageLite.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Feature(boolean noInit) { this.unknownFields = com.google.protobuf.ByteString.EMPTY;} - - private static final Feature defaultInstance; - public static Feature getDefaultInstance() { - return defaultInstance; - } - - public Feature getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.ByteString unknownFields; - private Feature( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.ByteString.Output unknownFieldsOutput = - com.google.protobuf.ByteString.newOutput(); - com.google.protobuf.CodedOutputStream unknownFieldsCodedOutput = - com.google.protobuf.CodedOutputStream.newInstance( - unknownFieldsOutput); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFieldsCodedOutput, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - Geobuf.Data.Geometry.Builder subBuilder = null; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - subBuilder = geometry_.toBuilder(); - } - geometry_ = input.readMessage(Geobuf.Data.Geometry.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(geometry_); - geometry_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000001; - break; - } - case 90: { - com.google.protobuf.ByteString bs = input.readBytes(); - idTypeCase_ = 11; - idType_ = bs; - break; - } - case 96: { - idTypeCase_ = 12; - idType_ = input.readSInt64(); - break; - } - case 106: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - values_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - values_.add(input.readMessage(Geobuf.Data.Value.PARSER, extensionRegistry)); - break; - } - case 112: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - properties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - properties_.add(input.readUInt32()); - break; - } - case 114: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010) && input.getBytesUntilLimit() > 0) { - properties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - while (input.getBytesUntilLimit() > 0) { - properties_.add(input.readUInt32()); - } - input.popLimit(limit); - break; - } - case 120: { - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - customProperties_.add(input.readUInt32()); - break; - } - case 122: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020) && input.getBytesUntilLimit() > 0) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - while (input.getBytesUntilLimit() > 0) { - customProperties_.add(input.readUInt32()); - } - input.popLimit(limit); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - values_ = java.util.Collections.unmodifiableList(values_); - } - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - properties_ = java.util.Collections.unmodifiableList(properties_); - } - if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - } - try { - unknownFieldsCodedOutput.flush(); - } catch (java.io.IOException e) { - // Should not happen - } finally { - unknownFields = unknownFieldsOutput.toByteString(); - } - makeExtensionsImmutable(); - } - } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Feature parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Feature(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - private int idTypeCase_ = 0; - private java.lang.Object idType_; - public enum IdTypeCase - implements com.google.protobuf.Internal.EnumLite { - ID(11), - INT_ID(12), - IDTYPE_NOT_SET(0); - private int value = 0; - private IdTypeCase(int value) { - this.value = value; - } - public static IdTypeCase valueOf(int value) { - switch (value) { - case 11: return ID; - case 12: return INT_ID; - case 0: return IDTYPE_NOT_SET; - default: throw new java.lang.IllegalArgumentException( - "Value is undefined for this oneof enum."); - } - } - public int getNumber() { - return this.value; - } - }; - - public IdTypeCase - getIdTypeCase() { - return IdTypeCase.valueOf( - idTypeCase_); - } - - public static final int GEOMETRY_FIELD_NUMBER = 1; - private Geobuf.Data.Geometry geometry_; - /** - * required .Data.Geometry geometry = 1; - */ - public boolean hasGeometry() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required .Data.Geometry geometry = 1; - */ - public Geobuf.Data.Geometry getGeometry() { - return geometry_; - } - - public static final int ID_FIELD_NUMBER = 11; - /** - * optional string id = 11; - */ - public boolean hasId() { - return idTypeCase_ == 11; - } - /** - * optional string id = 11; - */ - public java.lang.String getId() { - java.lang.Object ref = ""; - if (idTypeCase_ == 11) { - ref = idType_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8() && (idTypeCase_ == 11)) { - idType_ = s; - } - return s; - } - } - /** - * optional string id = 11; - */ - public com.google.protobuf.ByteString - getIdBytes() { - java.lang.Object ref = ""; - if (idTypeCase_ == 11) { - ref = idType_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (idTypeCase_ == 11) { - idType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int INT_ID_FIELD_NUMBER = 12; - /** - * optional sint64 int_id = 12; - */ - public boolean hasIntId() { - return idTypeCase_ == 12; - } - /** - * optional sint64 int_id = 12; - */ - public long getIntId() { - if (idTypeCase_ == 12) { - return (java.lang.Long) idType_; - } - return 0L; - } - - public static final int VALUES_FIELD_NUMBER = 13; - private java.util.List values_; - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - public java.util.List getValuesList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - public java.util.List - getValuesOrBuilderList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - * - *
-       * unique values
-       * 
- */ - public Geobuf.Data.ValueOrBuilder getValuesOrBuilder( - int index) { - return values_.get(index); - } - - public static final int PROPERTIES_FIELD_NUMBER = 14; - private java.util.List properties_; - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - public java.util.List - getPropertiesList() { - return properties_; - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - public int getPropertiesCount() { - return properties_.size(); - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-       * pairs of key/value indexes
-       * 
- */ - public int getProperties(int index) { - return properties_.get(index); - } - private int propertiesMemoizedSerializedSize = -1; - - public static final int CUSTOM_PROPERTIES_FIELD_NUMBER = 15; - private java.util.List customProperties_; - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - public java.util.List - getCustomPropertiesList() { - return customProperties_; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-       * arbitrary properties
-       * 
- */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - private int customPropertiesMemoizedSerializedSize = -1; - - private void initFields() { - geometry_ = Geobuf.Data.Geometry.getDefaultInstance(); - values_ = java.util.Collections.emptyList(); - properties_ = java.util.Collections.emptyList(); - customProperties_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (!hasGeometry()) { - memoizedIsInitialized = 0; - return false; - } - if (!getGeometry().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeMessage(1, geometry_); - } - if (idTypeCase_ == 11) { - output.writeBytes(11, getIdBytes()); - } - if (idTypeCase_ == 12) { - output.writeSInt64( - 12, (long)((java.lang.Long) idType_)); - } - for (int i = 0; i < values_.size(); i++) { - output.writeMessage(13, values_.get(i)); - } - if (getPropertiesList().size() > 0) { - output.writeRawVarint32(114); - output.writeRawVarint32(propertiesMemoizedSerializedSize); - } - for (int i = 0; i < properties_.size(); i++) { - output.writeUInt32NoTag(properties_.get(i)); - } - if (getCustomPropertiesList().size() > 0) { - output.writeRawVarint32(122); - output.writeRawVarint32(customPropertiesMemoizedSerializedSize); - } - for (int i = 0; i < customProperties_.size(); i++) { - output.writeUInt32NoTag(customProperties_.get(i)); - } - output.writeRawBytes(unknownFields); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, geometry_); - } - if (idTypeCase_ == 11) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(11, getIdBytes()); - } - if (idTypeCase_ == 12) { - size += com.google.protobuf.CodedOutputStream - .computeSInt64Size( - 12, (long)((java.lang.Long) idType_)); - } - for (int i = 0; i < values_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(13, values_.get(i)); - } - { - int dataSize = 0; - for (int i = 0; i < properties_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeUInt32SizeNoTag(properties_.get(i)); - } - size += dataSize; - if (!getPropertiesList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - propertiesMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - for (int i = 0; i < customProperties_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeUInt32SizeNoTag(customProperties_.get(i)); - } - size += dataSize; - if (!getCustomPropertiesList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - customPropertiesMemoizedSerializedSize = dataSize; - } - size += unknownFields.size(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static Geobuf.Data.Feature parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Feature parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Feature parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Feature parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Feature parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Feature parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static Geobuf.Data.Feature parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static Geobuf.Data.Feature parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static Geobuf.Data.Feature parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Feature parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(Geobuf.Data.Feature prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - /** - * Protobuf type {@code Data.Feature} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - Geobuf.Data.Feature, Builder> - implements - // @@protoc_insertion_point(builder_implements:Data.Feature) - Geobuf.Data.FeatureOrBuilder { - // Construct using Geobuf.Data.Feature.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - geometry_ = Geobuf.Data.Geometry.getDefaultInstance(); - bitField0_ = (bitField0_ & ~0x00000001); - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - properties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - idTypeCase_ = 0; - idType_ = null; - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public Geobuf.Data.Feature getDefaultInstanceForType() { - return Geobuf.Data.Feature.getDefaultInstance(); - } - - public Geobuf.Data.Feature build() { - Geobuf.Data.Feature result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Geobuf.Data.Feature buildPartial() { - Geobuf.Data.Feature result = new Geobuf.Data.Feature(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.geometry_ = geometry_; - if (idTypeCase_ == 11) { - result.idType_ = idType_; - } - if (idTypeCase_ == 12) { - result.idType_ = idType_; - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.values_ = values_; - if (((bitField0_ & 0x00000010) == 0x00000010)) { - properties_ = java.util.Collections.unmodifiableList(properties_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.properties_ = properties_; - if (((bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - bitField0_ = (bitField0_ & ~0x00000020); - } - result.customProperties_ = customProperties_; - result.bitField0_ = to_bitField0_; - result.idTypeCase_ = idTypeCase_; - return result; - } - - public Builder mergeFrom(Geobuf.Data.Feature other) { - if (other == Geobuf.Data.Feature.getDefaultInstance()) return this; - if (other.hasGeometry()) { - mergeGeometry(other.getGeometry()); - } - if (!other.values_.isEmpty()) { - if (values_.isEmpty()) { - values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureValuesIsMutable(); - values_.addAll(other.values_); - } - - } - if (!other.properties_.isEmpty()) { - if (properties_.isEmpty()) { - properties_ = other.properties_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensurePropertiesIsMutable(); - properties_.addAll(other.properties_); - } - - } - if (!other.customProperties_.isEmpty()) { - if (customProperties_.isEmpty()) { - customProperties_ = other.customProperties_; - bitField0_ = (bitField0_ & ~0x00000020); - } else { - ensureCustomPropertiesIsMutable(); - customProperties_.addAll(other.customProperties_); - } - - } - switch (other.getIdTypeCase()) { - case ID: { - idTypeCase_ = 11; - idType_ = other.idType_; - - break; - } - case INT_ID: { - setIntId(other.getIntId()); - break; - } - case IDTYPE_NOT_SET: { - break; - } - } - setUnknownFields( - getUnknownFields().concat(other.unknownFields)); - return this; - } - - public final boolean isInitialized() { - if (!hasGeometry()) { - - return false; - } - if (!getGeometry().isInitialized()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Geobuf.Data.Feature parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Geobuf.Data.Feature) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int idTypeCase_ = 0; - private java.lang.Object idType_; - public IdTypeCase - getIdTypeCase() { - return IdTypeCase.valueOf( - idTypeCase_); - } - - public Builder clearIdType() { - idTypeCase_ = 0; - idType_ = null; - return this; - } - - private int bitField0_; - - private Geobuf.Data.Geometry geometry_ = Geobuf.Data.Geometry.getDefaultInstance(); - /** - * required .Data.Geometry geometry = 1; - */ - public boolean hasGeometry() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required .Data.Geometry geometry = 1; - */ - public Geobuf.Data.Geometry getGeometry() { - return geometry_; - } - /** - * required .Data.Geometry geometry = 1; - */ - public Builder setGeometry(Geobuf.Data.Geometry value) { - if (value == null) { - throw new NullPointerException(); - } - geometry_ = value; - - bitField0_ |= 0x00000001; - return this; - } - /** - * required .Data.Geometry geometry = 1; - */ - public Builder setGeometry( - Geobuf.Data.Geometry.Builder builderForValue) { - geometry_ = builderForValue.build(); - - bitField0_ |= 0x00000001; - return this; - } - /** - * required .Data.Geometry geometry = 1; - */ - public Builder mergeGeometry(Geobuf.Data.Geometry value) { - if (((bitField0_ & 0x00000001) == 0x00000001) && - geometry_ != Geobuf.Data.Geometry.getDefaultInstance()) { - geometry_ = - Geobuf.Data.Geometry.newBuilder(geometry_).mergeFrom(value).buildPartial(); - } else { - geometry_ = value; - } - - bitField0_ |= 0x00000001; - return this; - } - /** - * required .Data.Geometry geometry = 1; - */ - public Builder clearGeometry() { - geometry_ = Geobuf.Data.Geometry.getDefaultInstance(); - - bitField0_ = (bitField0_ & ~0x00000001); - return this; - } - - /** - * optional string id = 11; - */ - public boolean hasId() { - return idTypeCase_ == 11; - } - /** - * optional string id = 11; - */ - public java.lang.String getId() { - java.lang.Object ref = ""; - if (idTypeCase_ == 11) { - ref = idType_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (idTypeCase_ == 11) { - if (bs.isValidUtf8()) { - idType_ = s; - } - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string id = 11; - */ - public com.google.protobuf.ByteString - getIdBytes() { - java.lang.Object ref = ""; - if (idTypeCase_ == 11) { - ref = idType_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (idTypeCase_ == 11) { - idType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string id = 11; - */ - public Builder setId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - idTypeCase_ = 11; - idType_ = value; - - return this; - } - /** - * optional string id = 11; - */ - public Builder clearId() { - if (idTypeCase_ == 11) { - idTypeCase_ = 0; - idType_ = null; - - } - return this; - } - /** - * optional string id = 11; - */ - public Builder setIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - idTypeCase_ = 11; - idType_ = value; - - return this; - } - - /** - * optional sint64 int_id = 12; - */ - public boolean hasIntId() { - return idTypeCase_ == 12; - } - /** - * optional sint64 int_id = 12; - */ - public long getIntId() { - if (idTypeCase_ == 12) { - return (java.lang.Long) idType_; - } - return 0L; - } - /** - * optional sint64 int_id = 12; - */ - public Builder setIntId(long value) { - idTypeCase_ = 12; - idType_ = value; - - return this; - } - /** - * optional sint64 int_id = 12; - */ - public Builder clearIntId() { - if (idTypeCase_ == 12) { - idTypeCase_ = 0; - idType_ = null; - - } - return this; - } - - private java.util.List values_ = - java.util.Collections.emptyList(); - private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000008; - } - } - - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public java.util.List getValuesList() { - return java.util.Collections.unmodifiableList(values_); - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder setValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.set(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder setValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.set(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder addValues(Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(value); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder addValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder addValues( - Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder addValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder addAllValues( - java.lang.Iterable values) { - ensureValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, values_); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder clearValues() { - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - - return this; - } - /** - * repeated .Data.Value values = 13; - * - *
-         * unique values
-         * 
- */ - public Builder removeValues(int index) { - ensureValuesIsMutable(); - values_.remove(index); - - return this; - } - - private java.util.List properties_ = java.util.Collections.emptyList(); - private void ensurePropertiesIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - properties_ = new java.util.ArrayList(properties_); - bitField0_ |= 0x00000010; - } - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public java.util.List - getPropertiesList() { - return java.util.Collections.unmodifiableList(properties_); - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public int getPropertiesCount() { - return properties_.size(); - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public int getProperties(int index) { - return properties_.get(index); - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public Builder setProperties( - int index, int value) { - ensurePropertiesIsMutable(); - properties_.set(index, value); - - return this; - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public Builder addProperties(int value) { - ensurePropertiesIsMutable(); - properties_.add(value); - - return this; - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public Builder addAllProperties( - java.lang.Iterable values) { - ensurePropertiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, properties_); - - return this; - } - /** - * repeated uint32 properties = 14 [packed = true]; - * - *
-         * pairs of key/value indexes
-         * 
- */ - public Builder clearProperties() { - properties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - - return this; - } - - private java.util.List customProperties_ = java.util.Collections.emptyList(); - private void ensureCustomPropertiesIsMutable() { - if (!((bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = new java.util.ArrayList(customProperties_); - bitField0_ |= 0x00000020; - } - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public java.util.List - getCustomPropertiesList() { - return java.util.Collections.unmodifiableList(customProperties_); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public Builder setCustomProperties( - int index, int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.set(index, value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public Builder addCustomProperties(int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.add(value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public Builder addAllCustomProperties( - java.lang.Iterable values) { - ensureCustomPropertiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, customProperties_); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - * - *
-         * arbitrary properties
-         * 
- */ - public Builder clearCustomProperties() { - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - - return this; - } - - // @@protoc_insertion_point(builder_scope:Data.Feature) - } - - static { - defaultInstance = new Feature(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:Data.Feature) - } - - public interface GeometryOrBuilder extends - // @@protoc_insertion_point(interface_extends:Data.Geometry) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * required .Data.Geometry.Type type = 1; - */ - boolean hasType(); - /** - * required .Data.Geometry.Type type = 1; - */ - Geobuf.Data.Geometry.Type getType(); - - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - java.util.List getLengthsList(); - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - int getLengthsCount(); - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - int getLengths(int index); - - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - java.util.List getCoordsList(); - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - int getCoordsCount(); - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - long getCoords(int index); - - /** - * repeated .Data.Geometry geometries = 4; - */ - java.util.List - getGeometriesList(); - /** - * repeated .Data.Geometry geometries = 4; - */ - Geobuf.Data.Geometry getGeometries(int index); - /** - * repeated .Data.Geometry geometries = 4; - */ - int getGeometriesCount(); - - /** - * repeated .Data.Value values = 13; - */ - java.util.List - getValuesList(); - /** - * repeated .Data.Value values = 13; - */ - Geobuf.Data.Value getValues(int index); - /** - * repeated .Data.Value values = 13; - */ - int getValuesCount(); - - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - java.util.List getCustomPropertiesList(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - int getCustomPropertiesCount(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - int getCustomProperties(int index); - } - /** - * Protobuf type {@code Data.Geometry} - */ - public static final class Geometry extends - com.google.protobuf.GeneratedMessageLite implements - // @@protoc_insertion_point(message_implements:Data.Geometry) - GeometryOrBuilder { - // Use Geometry.newBuilder() to construct. - private Geometry(com.google.protobuf.GeneratedMessageLite.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Geometry(boolean noInit) { this.unknownFields = com.google.protobuf.ByteString.EMPTY;} - - private static final Geometry defaultInstance; - public static Geometry getDefaultInstance() { - return defaultInstance; - } - - public Geometry getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.ByteString unknownFields; - private Geometry( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.ByteString.Output unknownFieldsOutput = - com.google.protobuf.ByteString.newOutput(); - com.google.protobuf.CodedOutputStream unknownFieldsCodedOutput = - com.google.protobuf.CodedOutputStream.newInstance( - unknownFieldsOutput); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFieldsCodedOutput, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - int rawValue = input.readEnum(); - Geobuf.Data.Geometry.Type value = Geobuf.Data.Geometry.Type.valueOf(rawValue); - if (value == null) { - unknownFieldsCodedOutput.writeRawVarint32(tag); - unknownFieldsCodedOutput.writeRawVarint32(rawValue); - } else { - bitField0_ |= 0x00000001; - type_ = value; - } - break; - } - case 16: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - lengths_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - lengths_.add(input.readUInt32()); - break; - } - case 18: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { - lengths_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - while (input.getBytesUntilLimit() > 0) { - lengths_.add(input.readUInt32()); - } - input.popLimit(limit); - break; - } - case 24: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - coords_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - coords_.add(input.readSInt64()); - break; - } - case 26: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) { - coords_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - while (input.getBytesUntilLimit() > 0) { - coords_.add(input.readSInt64()); - } - input.popLimit(limit); - break; - } - case 34: { - if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - geometries_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; - } - geometries_.add(input.readMessage(Geobuf.Data.Geometry.PARSER, extensionRegistry)); - break; - } - case 106: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - values_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - values_.add(input.readMessage(Geobuf.Data.Value.PARSER, extensionRegistry)); - break; - } - case 120: { - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - customProperties_.add(input.readUInt32()); - break; - } - case 122: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020) && input.getBytesUntilLimit() > 0) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - while (input.getBytesUntilLimit() > 0) { - customProperties_.add(input.readUInt32()); - } - input.popLimit(limit); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - lengths_ = java.util.Collections.unmodifiableList(lengths_); - } - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - coords_ = java.util.Collections.unmodifiableList(coords_); - } - if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) { - geometries_ = java.util.Collections.unmodifiableList(geometries_); - } - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - values_ = java.util.Collections.unmodifiableList(values_); - } - if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - } - try { - unknownFieldsCodedOutput.flush(); - } catch (java.io.IOException e) { - // Should not happen - } finally { - unknownFields = unknownFieldsOutput.toByteString(); - } - makeExtensionsImmutable(); - } - } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Geometry parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Geometry(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - /** - * Protobuf enum {@code Data.Geometry.Type} - */ - public enum Type - implements com.google.protobuf.Internal.EnumLite { - /** - * POINT = 0; - */ - POINT(0, 0), - /** - * MULTIPOINT = 1; - */ - MULTIPOINT(1, 1), - /** - * LINESTRING = 2; - */ - LINESTRING(2, 2), - /** - * MULTILINESTRING = 3; - */ - MULTILINESTRING(3, 3), - /** - * POLYGON = 4; - */ - POLYGON(4, 4), - /** - * MULTIPOLYGON = 5; - */ - MULTIPOLYGON(5, 5), - /** - * GEOMETRYCOLLECTION = 6; - */ - GEOMETRYCOLLECTION(6, 6), - ; - - /** - * POINT = 0; - */ - public static final int POINT_VALUE = 0; - /** - * MULTIPOINT = 1; - */ - public static final int MULTIPOINT_VALUE = 1; - /** - * LINESTRING = 2; - */ - public static final int LINESTRING_VALUE = 2; - /** - * MULTILINESTRING = 3; - */ - public static final int MULTILINESTRING_VALUE = 3; - /** - * POLYGON = 4; - */ - public static final int POLYGON_VALUE = 4; - /** - * MULTIPOLYGON = 5; - */ - public static final int MULTIPOLYGON_VALUE = 5; - /** - * GEOMETRYCOLLECTION = 6; - */ - public static final int GEOMETRYCOLLECTION_VALUE = 6; - - - public final int getNumber() { return value; } - - public static Type valueOf(int value) { - switch (value) { - case 0: return POINT; - case 1: return MULTIPOINT; - case 2: return LINESTRING; - case 3: return MULTILINESTRING; - case 4: return POLYGON; - case 5: return MULTIPOLYGON; - case 6: return GEOMETRYCOLLECTION; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public Type findValueByNumber(int number) { - return Type.valueOf(number); - } - }; - - private final int value; - - private Type(int index, int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:Data.Geometry.Type) - } - - private int bitField0_; - public static final int TYPE_FIELD_NUMBER = 1; - private Geobuf.Data.Geometry.Type type_; - /** - * required .Data.Geometry.Type type = 1; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required .Data.Geometry.Type type = 1; - */ - public Geobuf.Data.Geometry.Type getType() { - return type_; - } - - public static final int LENGTHS_FIELD_NUMBER = 2; - private java.util.List lengths_; - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - public java.util.List - getLengthsList() { - return lengths_; - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - public int getLengthsCount() { - return lengths_.size(); - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-       * coordinate structure in lengths
-       * 
- */ - public int getLengths(int index) { - return lengths_.get(index); - } - private int lengthsMemoizedSerializedSize = -1; - - public static final int COORDS_FIELD_NUMBER = 3; - private java.util.List coords_; - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - public java.util.List - getCoordsList() { - return coords_; - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - public int getCoordsCount() { - return coords_.size(); - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-       * delta-encoded integer values
-       * 
- */ - public long getCoords(int index) { - return coords_.get(index); - } - private int coordsMemoizedSerializedSize = -1; - - public static final int GEOMETRIES_FIELD_NUMBER = 4; - private java.util.List geometries_; - /** - * repeated .Data.Geometry geometries = 4; - */ - public java.util.List getGeometriesList() { - return geometries_; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public java.util.List - getGeometriesOrBuilderList() { - return geometries_; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public int getGeometriesCount() { - return geometries_.size(); - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Geobuf.Data.Geometry getGeometries(int index) { - return geometries_.get(index); - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Geobuf.Data.GeometryOrBuilder getGeometriesOrBuilder( - int index) { - return geometries_.get(index); - } - - public static final int VALUES_FIELD_NUMBER = 13; - private java.util.List values_; - /** - * repeated .Data.Value values = 13; - */ - public java.util.List getValuesList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - */ - public java.util.List - getValuesOrBuilderList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.ValueOrBuilder getValuesOrBuilder( - int index) { - return values_.get(index); - } - - public static final int CUSTOM_PROPERTIES_FIELD_NUMBER = 15; - private java.util.List customProperties_; - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public java.util.List - getCustomPropertiesList() { - return customProperties_; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - private int customPropertiesMemoizedSerializedSize = -1; - - private void initFields() { - type_ = Geobuf.Data.Geometry.Type.POINT; - lengths_ = java.util.Collections.emptyList(); - coords_ = java.util.Collections.emptyList(); - geometries_ = java.util.Collections.emptyList(); - values_ = java.util.Collections.emptyList(); - customProperties_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (!hasType()) { - memoizedIsInitialized = 0; - return false; - } - for (int i = 0; i < getGeometriesCount(); i++) { - if (!getGeometries(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeEnum(1, type_.getNumber()); - } - if (getLengthsList().size() > 0) { - output.writeRawVarint32(18); - output.writeRawVarint32(lengthsMemoizedSerializedSize); - } - for (int i = 0; i < lengths_.size(); i++) { - output.writeUInt32NoTag(lengths_.get(i)); - } - if (getCoordsList().size() > 0) { - output.writeRawVarint32(26); - output.writeRawVarint32(coordsMemoizedSerializedSize); - } - for (int i = 0; i < coords_.size(); i++) { - output.writeSInt64NoTag(coords_.get(i)); - } - for (int i = 0; i < geometries_.size(); i++) { - output.writeMessage(4, geometries_.get(i)); - } - for (int i = 0; i < values_.size(); i++) { - output.writeMessage(13, values_.get(i)); - } - if (getCustomPropertiesList().size() > 0) { - output.writeRawVarint32(122); - output.writeRawVarint32(customPropertiesMemoizedSerializedSize); - } - for (int i = 0; i < customProperties_.size(); i++) { - output.writeUInt32NoTag(customProperties_.get(i)); - } - output.writeRawBytes(unknownFields); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, type_.getNumber()); - } - { - int dataSize = 0; - for (int i = 0; i < lengths_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeUInt32SizeNoTag(lengths_.get(i)); - } - size += dataSize; - if (!getLengthsList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - lengthsMemoizedSerializedSize = dataSize; - } - { - int dataSize = 0; - for (int i = 0; i < coords_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeSInt64SizeNoTag(coords_.get(i)); - } - size += dataSize; - if (!getCoordsList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - coordsMemoizedSerializedSize = dataSize; - } - for (int i = 0; i < geometries_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, geometries_.get(i)); - } - for (int i = 0; i < values_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(13, values_.get(i)); - } - { - int dataSize = 0; - for (int i = 0; i < customProperties_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeUInt32SizeNoTag(customProperties_.get(i)); - } - size += dataSize; - if (!getCustomPropertiesList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - customPropertiesMemoizedSerializedSize = dataSize; - } - size += unknownFields.size(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static Geobuf.Data.Geometry parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Geometry parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Geometry parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Geometry parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Geometry parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Geometry parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static Geobuf.Data.Geometry parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static Geobuf.Data.Geometry parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static Geobuf.Data.Geometry parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Geometry parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(Geobuf.Data.Geometry prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - /** - * Protobuf type {@code Data.Geometry} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - Geobuf.Data.Geometry, Builder> - implements - // @@protoc_insertion_point(builder_implements:Data.Geometry) - Geobuf.Data.GeometryOrBuilder { - // Construct using Geobuf.Data.Geometry.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - type_ = Geobuf.Data.Geometry.Type.POINT; - bitField0_ = (bitField0_ & ~0x00000001); - lengths_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - coords_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - geometries_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public Geobuf.Data.Geometry getDefaultInstanceForType() { - return Geobuf.Data.Geometry.getDefaultInstance(); - } - - public Geobuf.Data.Geometry build() { - Geobuf.Data.Geometry result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Geobuf.Data.Geometry buildPartial() { - Geobuf.Data.Geometry result = new Geobuf.Data.Geometry(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.type_ = type_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - lengths_ = java.util.Collections.unmodifiableList(lengths_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.lengths_ = lengths_; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - coords_ = java.util.Collections.unmodifiableList(coords_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.coords_ = coords_; - if (((bitField0_ & 0x00000008) == 0x00000008)) { - geometries_ = java.util.Collections.unmodifiableList(geometries_); - bitField0_ = (bitField0_ & ~0x00000008); - } - result.geometries_ = geometries_; - if (((bitField0_ & 0x00000010) == 0x00000010)) { - values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.values_ = values_; - if (((bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - bitField0_ = (bitField0_ & ~0x00000020); - } - result.customProperties_ = customProperties_; - result.bitField0_ = to_bitField0_; - return result; - } - - public Builder mergeFrom(Geobuf.Data.Geometry other) { - if (other == Geobuf.Data.Geometry.getDefaultInstance()) return this; - if (other.hasType()) { - setType(other.getType()); - } - if (!other.lengths_.isEmpty()) { - if (lengths_.isEmpty()) { - lengths_ = other.lengths_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureLengthsIsMutable(); - lengths_.addAll(other.lengths_); - } - - } - if (!other.coords_.isEmpty()) { - if (coords_.isEmpty()) { - coords_ = other.coords_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureCoordsIsMutable(); - coords_.addAll(other.coords_); - } - - } - if (!other.geometries_.isEmpty()) { - if (geometries_.isEmpty()) { - geometries_ = other.geometries_; - bitField0_ = (bitField0_ & ~0x00000008); - } else { - ensureGeometriesIsMutable(); - geometries_.addAll(other.geometries_); - } - - } - if (!other.values_.isEmpty()) { - if (values_.isEmpty()) { - values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureValuesIsMutable(); - values_.addAll(other.values_); - } - - } - if (!other.customProperties_.isEmpty()) { - if (customProperties_.isEmpty()) { - customProperties_ = other.customProperties_; - bitField0_ = (bitField0_ & ~0x00000020); - } else { - ensureCustomPropertiesIsMutable(); - customProperties_.addAll(other.customProperties_); - } - - } - setUnknownFields( - getUnknownFields().concat(other.unknownFields)); - return this; - } - - public final boolean isInitialized() { - if (!hasType()) { - - return false; - } - for (int i = 0; i < getGeometriesCount(); i++) { - if (!getGeometries(i).isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Geobuf.Data.Geometry parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Geobuf.Data.Geometry) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private Geobuf.Data.Geometry.Type type_ = Geobuf.Data.Geometry.Type.POINT; - /** - * required .Data.Geometry.Type type = 1; - */ - public boolean hasType() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required .Data.Geometry.Type type = 1; - */ - public Geobuf.Data.Geometry.Type getType() { - return type_; - } - /** - * required .Data.Geometry.Type type = 1; - */ - public Builder setType(Geobuf.Data.Geometry.Type value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - type_ = value; - - return this; - } - /** - * required .Data.Geometry.Type type = 1; - */ - public Builder clearType() { - bitField0_ = (bitField0_ & ~0x00000001); - type_ = Geobuf.Data.Geometry.Type.POINT; - - return this; - } - - private java.util.List lengths_ = java.util.Collections.emptyList(); - private void ensureLengthsIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - lengths_ = new java.util.ArrayList(lengths_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public java.util.List - getLengthsList() { - return java.util.Collections.unmodifiableList(lengths_); - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public int getLengthsCount() { - return lengths_.size(); - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public int getLengths(int index) { - return lengths_.get(index); - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public Builder setLengths( - int index, int value) { - ensureLengthsIsMutable(); - lengths_.set(index, value); - - return this; - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public Builder addLengths(int value) { - ensureLengthsIsMutable(); - lengths_.add(value); - - return this; - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public Builder addAllLengths( - java.lang.Iterable values) { - ensureLengthsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, lengths_); - - return this; - } - /** - * repeated uint32 lengths = 2 [packed = true]; - * - *
-         * coordinate structure in lengths
-         * 
- */ - public Builder clearLengths() { - lengths_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - - return this; - } - - private java.util.List coords_ = java.util.Collections.emptyList(); - private void ensureCoordsIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - coords_ = new java.util.ArrayList(coords_); - bitField0_ |= 0x00000004; - } - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public java.util.List - getCoordsList() { - return java.util.Collections.unmodifiableList(coords_); - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public int getCoordsCount() { - return coords_.size(); - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public long getCoords(int index) { - return coords_.get(index); - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public Builder setCoords( - int index, long value) { - ensureCoordsIsMutable(); - coords_.set(index, value); - - return this; - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public Builder addCoords(long value) { - ensureCoordsIsMutable(); - coords_.add(value); - - return this; - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public Builder addAllCoords( - java.lang.Iterable values) { - ensureCoordsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, coords_); - - return this; - } - /** - * repeated sint64 coords = 3 [packed = true]; - * - *
-         * delta-encoded integer values
-         * 
- */ - public Builder clearCoords() { - coords_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - - return this; - } - - private java.util.List geometries_ = - java.util.Collections.emptyList(); - private void ensureGeometriesIsMutable() { - if (!((bitField0_ & 0x00000008) == 0x00000008)) { - geometries_ = new java.util.ArrayList(geometries_); - bitField0_ |= 0x00000008; - } - } - - /** - * repeated .Data.Geometry geometries = 4; - */ - public java.util.List getGeometriesList() { - return java.util.Collections.unmodifiableList(geometries_); - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public int getGeometriesCount() { - return geometries_.size(); - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Geobuf.Data.Geometry getGeometries(int index) { - return geometries_.get(index); - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder setGeometries( - int index, Geobuf.Data.Geometry value) { - if (value == null) { - throw new NullPointerException(); - } - ensureGeometriesIsMutable(); - geometries_.set(index, value); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder setGeometries( - int index, Geobuf.Data.Geometry.Builder builderForValue) { - ensureGeometriesIsMutable(); - geometries_.set(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder addGeometries(Geobuf.Data.Geometry value) { - if (value == null) { - throw new NullPointerException(); - } - ensureGeometriesIsMutable(); - geometries_.add(value); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder addGeometries( - int index, Geobuf.Data.Geometry value) { - if (value == null) { - throw new NullPointerException(); - } - ensureGeometriesIsMutable(); - geometries_.add(index, value); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder addGeometries( - Geobuf.Data.Geometry.Builder builderForValue) { - ensureGeometriesIsMutable(); - geometries_.add(builderForValue.build()); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder addGeometries( - int index, Geobuf.Data.Geometry.Builder builderForValue) { - ensureGeometriesIsMutable(); - geometries_.add(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder addAllGeometries( - java.lang.Iterable values) { - ensureGeometriesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, geometries_); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder clearGeometries() { - geometries_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); - - return this; - } - /** - * repeated .Data.Geometry geometries = 4; - */ - public Builder removeGeometries(int index) { - ensureGeometriesIsMutable(); - geometries_.remove(index); - - return this; - } - - private java.util.List values_ = - java.util.Collections.emptyList(); - private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000010; - } - } - - /** - * repeated .Data.Value values = 13; - */ - public java.util.List getValuesList() { - return java.util.Collections.unmodifiableList(values_); - } - /** - * repeated .Data.Value values = 13; - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - */ - public Builder setValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.set(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder setValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.set(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues(Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addAllValues( - java.lang.Iterable values) { - ensureValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, values_); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder clearValues() { - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder removeValues(int index) { - ensureValuesIsMutable(); - values_.remove(index); - - return this; - } - - private java.util.List customProperties_ = java.util.Collections.emptyList(); - private void ensureCustomPropertiesIsMutable() { - if (!((bitField0_ & 0x00000020) == 0x00000020)) { - customProperties_ = new java.util.ArrayList(customProperties_); - bitField0_ |= 0x00000020; - } - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public java.util.List - getCustomPropertiesList() { - return java.util.Collections.unmodifiableList(customProperties_); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder setCustomProperties( - int index, int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.set(index, value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder addCustomProperties(int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.add(value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder addAllCustomProperties( - java.lang.Iterable values) { - ensureCustomPropertiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, customProperties_); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder clearCustomProperties() { - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - - return this; - } - - // @@protoc_insertion_point(builder_scope:Data.Geometry) - } - - static { - defaultInstance = new Geometry(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:Data.Geometry) - } - - public interface FeatureCollectionOrBuilder extends - // @@protoc_insertion_point(interface_extends:Data.FeatureCollection) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * repeated .Data.Feature features = 1; - */ - java.util.List - getFeaturesList(); - /** - * repeated .Data.Feature features = 1; - */ - Geobuf.Data.Feature getFeatures(int index); - /** - * repeated .Data.Feature features = 1; - */ - int getFeaturesCount(); - - /** - * repeated .Data.Value values = 13; - */ - java.util.List - getValuesList(); - /** - * repeated .Data.Value values = 13; - */ - Geobuf.Data.Value getValues(int index); - /** - * repeated .Data.Value values = 13; - */ - int getValuesCount(); - - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - java.util.List getCustomPropertiesList(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - int getCustomPropertiesCount(); - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - int getCustomProperties(int index); - } - /** - * Protobuf type {@code Data.FeatureCollection} - */ - public static final class FeatureCollection extends - com.google.protobuf.GeneratedMessageLite implements - // @@protoc_insertion_point(message_implements:Data.FeatureCollection) - FeatureCollectionOrBuilder { - // Use FeatureCollection.newBuilder() to construct. - private FeatureCollection(com.google.protobuf.GeneratedMessageLite.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private FeatureCollection(boolean noInit) { this.unknownFields = com.google.protobuf.ByteString.EMPTY;} - - private static final FeatureCollection defaultInstance; - public static FeatureCollection getDefaultInstance() { - return defaultInstance; - } - - public FeatureCollection getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.ByteString unknownFields; - private FeatureCollection( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.ByteString.Output unknownFieldsOutput = - com.google.protobuf.ByteString.newOutput(); - com.google.protobuf.CodedOutputStream unknownFieldsCodedOutput = - com.google.protobuf.CodedOutputStream.newInstance( - unknownFieldsOutput); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFieldsCodedOutput, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - features_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - features_.add(input.readMessage(Geobuf.Data.Feature.PARSER, extensionRegistry)); - break; - } - case 106: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - values_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000002; - } - values_.add(input.readMessage(Geobuf.Data.Value.PARSER, extensionRegistry)); - break; - } - case 120: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - customProperties_.add(input.readUInt32()); - break; - } - case 122: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) { - customProperties_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - while (input.getBytesUntilLimit() > 0) { - customProperties_.add(input.readUInt32()); - } - input.popLimit(limit); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - features_ = java.util.Collections.unmodifiableList(features_); - } - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - values_ = java.util.Collections.unmodifiableList(values_); - } - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - } - try { - unknownFieldsCodedOutput.flush(); - } catch (java.io.IOException e) { - // Should not happen - } finally { - unknownFields = unknownFieldsOutput.toByteString(); - } - makeExtensionsImmutable(); - } - } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public FeatureCollection parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new FeatureCollection(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public static final int FEATURES_FIELD_NUMBER = 1; - private java.util.List features_; - /** - * repeated .Data.Feature features = 1; - */ - public java.util.List getFeaturesList() { - return features_; - } - /** - * repeated .Data.Feature features = 1; - */ - public java.util.List - getFeaturesOrBuilderList() { - return features_; - } - /** - * repeated .Data.Feature features = 1; - */ - public int getFeaturesCount() { - return features_.size(); - } - /** - * repeated .Data.Feature features = 1; - */ - public Geobuf.Data.Feature getFeatures(int index) { - return features_.get(index); - } - /** - * repeated .Data.Feature features = 1; - */ - public Geobuf.Data.FeatureOrBuilder getFeaturesOrBuilder( - int index) { - return features_.get(index); - } - - public static final int VALUES_FIELD_NUMBER = 13; - private java.util.List values_; - /** - * repeated .Data.Value values = 13; - */ - public java.util.List getValuesList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - */ - public java.util.List - getValuesOrBuilderList() { - return values_; - } - /** - * repeated .Data.Value values = 13; - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.ValueOrBuilder getValuesOrBuilder( - int index) { - return values_.get(index); - } - - public static final int CUSTOM_PROPERTIES_FIELD_NUMBER = 15; - private java.util.List customProperties_; - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public java.util.List - getCustomPropertiesList() { - return customProperties_; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - private int customPropertiesMemoizedSerializedSize = -1; - - private void initFields() { - features_ = java.util.Collections.emptyList(); - values_ = java.util.Collections.emptyList(); - customProperties_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - for (int i = 0; i < getFeaturesCount(); i++) { - if (!getFeatures(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < features_.size(); i++) { - output.writeMessage(1, features_.get(i)); - } - for (int i = 0; i < values_.size(); i++) { - output.writeMessage(13, values_.get(i)); - } - if (getCustomPropertiesList().size() > 0) { - output.writeRawVarint32(122); - output.writeRawVarint32(customPropertiesMemoizedSerializedSize); - } - for (int i = 0; i < customProperties_.size(); i++) { - output.writeUInt32NoTag(customProperties_.get(i)); - } - output.writeRawBytes(unknownFields); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < features_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, features_.get(i)); - } - for (int i = 0; i < values_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(13, values_.get(i)); - } - { - int dataSize = 0; - for (int i = 0; i < customProperties_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeUInt32SizeNoTag(customProperties_.get(i)); - } - size += dataSize; - if (!getCustomPropertiesList().isEmpty()) { - size += 1; - size += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(dataSize); - } - customPropertiesMemoizedSerializedSize = dataSize; - } - size += unknownFields.size(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static Geobuf.Data.FeatureCollection parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.FeatureCollection parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.FeatureCollection parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.FeatureCollection parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.FeatureCollection parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.FeatureCollection parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static Geobuf.Data.FeatureCollection parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static Geobuf.Data.FeatureCollection parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static Geobuf.Data.FeatureCollection parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.FeatureCollection parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(Geobuf.Data.FeatureCollection prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - /** - * Protobuf type {@code Data.FeatureCollection} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - Geobuf.Data.FeatureCollection, Builder> - implements - // @@protoc_insertion_point(builder_implements:Data.FeatureCollection) - Geobuf.Data.FeatureCollectionOrBuilder { - // Construct using Geobuf.Data.FeatureCollection.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - features_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public Geobuf.Data.FeatureCollection getDefaultInstanceForType() { - return Geobuf.Data.FeatureCollection.getDefaultInstance(); - } - - public Geobuf.Data.FeatureCollection build() { - Geobuf.Data.FeatureCollection result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Geobuf.Data.FeatureCollection buildPartial() { - Geobuf.Data.FeatureCollection result = new Geobuf.Data.FeatureCollection(this); - int from_bitField0_ = bitField0_; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - features_ = java.util.Collections.unmodifiableList(features_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.features_ = features_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - values_ = java.util.Collections.unmodifiableList(values_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.values_ = values_; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - customProperties_ = java.util.Collections.unmodifiableList(customProperties_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.customProperties_ = customProperties_; - return result; - } - - public Builder mergeFrom(Geobuf.Data.FeatureCollection other) { - if (other == Geobuf.Data.FeatureCollection.getDefaultInstance()) return this; - if (!other.features_.isEmpty()) { - if (features_.isEmpty()) { - features_ = other.features_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureFeaturesIsMutable(); - features_.addAll(other.features_); - } - - } - if (!other.values_.isEmpty()) { - if (values_.isEmpty()) { - values_ = other.values_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureValuesIsMutable(); - values_.addAll(other.values_); - } - - } - if (!other.customProperties_.isEmpty()) { - if (customProperties_.isEmpty()) { - customProperties_ = other.customProperties_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureCustomPropertiesIsMutable(); - customProperties_.addAll(other.customProperties_); - } - - } - setUnknownFields( - getUnknownFields().concat(other.unknownFields)); - return this; - } - - public final boolean isInitialized() { - for (int i = 0; i < getFeaturesCount(); i++) { - if (!getFeatures(i).isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Geobuf.Data.FeatureCollection parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Geobuf.Data.FeatureCollection) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.util.List features_ = - java.util.Collections.emptyList(); - private void ensureFeaturesIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - features_ = new java.util.ArrayList(features_); - bitField0_ |= 0x00000001; - } - } - - /** - * repeated .Data.Feature features = 1; - */ - public java.util.List getFeaturesList() { - return java.util.Collections.unmodifiableList(features_); - } - /** - * repeated .Data.Feature features = 1; - */ - public int getFeaturesCount() { - return features_.size(); - } - /** - * repeated .Data.Feature features = 1; - */ - public Geobuf.Data.Feature getFeatures(int index) { - return features_.get(index); - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder setFeatures( - int index, Geobuf.Data.Feature value) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeaturesIsMutable(); - features_.set(index, value); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder setFeatures( - int index, Geobuf.Data.Feature.Builder builderForValue) { - ensureFeaturesIsMutable(); - features_.set(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder addFeatures(Geobuf.Data.Feature value) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeaturesIsMutable(); - features_.add(value); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder addFeatures( - int index, Geobuf.Data.Feature value) { - if (value == null) { - throw new NullPointerException(); - } - ensureFeaturesIsMutable(); - features_.add(index, value); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder addFeatures( - Geobuf.Data.Feature.Builder builderForValue) { - ensureFeaturesIsMutable(); - features_.add(builderForValue.build()); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder addFeatures( - int index, Geobuf.Data.Feature.Builder builderForValue) { - ensureFeaturesIsMutable(); - features_.add(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder addAllFeatures( - java.lang.Iterable values) { - ensureFeaturesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, features_); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder clearFeatures() { - features_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - - return this; - } - /** - * repeated .Data.Feature features = 1; - */ - public Builder removeFeatures(int index) { - ensureFeaturesIsMutable(); - features_.remove(index); - - return this; - } - - private java.util.List values_ = - java.util.Collections.emptyList(); - private void ensureValuesIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - values_ = new java.util.ArrayList(values_); - bitField0_ |= 0x00000002; - } - } - - /** - * repeated .Data.Value values = 13; - */ - public java.util.List getValuesList() { - return java.util.Collections.unmodifiableList(values_); - } - /** - * repeated .Data.Value values = 13; - */ - public int getValuesCount() { - return values_.size(); - } - /** - * repeated .Data.Value values = 13; - */ - public Geobuf.Data.Value getValues(int index) { - return values_.get(index); - } - /** - * repeated .Data.Value values = 13; - */ - public Builder setValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.set(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder setValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.set(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues(Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - int index, Geobuf.Data.Value value) { - if (value == null) { - throw new NullPointerException(); - } - ensureValuesIsMutable(); - values_.add(index, value); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addValues( - int index, Geobuf.Data.Value.Builder builderForValue) { - ensureValuesIsMutable(); - values_.add(index, builderForValue.build()); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder addAllValues( - java.lang.Iterable values) { - ensureValuesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, values_); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder clearValues() { - values_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000002); - - return this; - } - /** - * repeated .Data.Value values = 13; - */ - public Builder removeValues(int index) { - ensureValuesIsMutable(); - values_.remove(index); - - return this; - } - - private java.util.List customProperties_ = java.util.Collections.emptyList(); - private void ensureCustomPropertiesIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - customProperties_ = new java.util.ArrayList(customProperties_); - bitField0_ |= 0x00000004; - } - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public java.util.List - getCustomPropertiesList() { - return java.util.Collections.unmodifiableList(customProperties_); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomPropertiesCount() { - return customProperties_.size(); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public int getCustomProperties(int index) { - return customProperties_.get(index); - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder setCustomProperties( - int index, int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.set(index, value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder addCustomProperties(int value) { - ensureCustomPropertiesIsMutable(); - customProperties_.add(value); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder addAllCustomProperties( - java.lang.Iterable values) { - ensureCustomPropertiesIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, customProperties_); - - return this; - } - /** - * repeated uint32 custom_properties = 15 [packed = true]; - */ - public Builder clearCustomProperties() { - customProperties_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - - return this; - } - - // @@protoc_insertion_point(builder_scope:Data.FeatureCollection) - } - - static { - defaultInstance = new FeatureCollection(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:Data.FeatureCollection) - } - - public interface ValueOrBuilder extends - // @@protoc_insertion_point(interface_extends:Data.Value) - com.google.protobuf.MessageLiteOrBuilder { - - /** - * optional string string_value = 1; - */ - boolean hasStringValue(); - /** - * optional string string_value = 1; - */ - java.lang.String getStringValue(); - /** - * optional string string_value = 1; - */ - com.google.protobuf.ByteString - getStringValueBytes(); - - /** - * optional double double_value = 2; - */ - boolean hasDoubleValue(); - /** - * optional double double_value = 2; - */ - double getDoubleValue(); - - /** - * optional uint64 pos_int_value = 3; - */ - boolean hasPosIntValue(); - /** - * optional uint64 pos_int_value = 3; - */ - long getPosIntValue(); - - /** - * optional uint64 neg_int_value = 4; - */ - boolean hasNegIntValue(); - /** - * optional uint64 neg_int_value = 4; - */ - long getNegIntValue(); - - /** - * optional bool bool_value = 5; - */ - boolean hasBoolValue(); - /** - * optional bool bool_value = 5; - */ - boolean getBoolValue(); - - /** - * optional string json_value = 6; - */ - boolean hasJsonValue(); - /** - * optional string json_value = 6; - */ - java.lang.String getJsonValue(); - /** - * optional string json_value = 6; - */ - com.google.protobuf.ByteString - getJsonValueBytes(); - } - /** - * Protobuf type {@code Data.Value} - */ - public static final class Value extends - com.google.protobuf.GeneratedMessageLite implements - // @@protoc_insertion_point(message_implements:Data.Value) - ValueOrBuilder { - // Use Value.newBuilder() to construct. - private Value(com.google.protobuf.GeneratedMessageLite.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Value(boolean noInit) { this.unknownFields = com.google.protobuf.ByteString.EMPTY;} - - private static final Value defaultInstance; - public static Value getDefaultInstance() { - return defaultInstance; - } - - public Value getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.ByteString unknownFields; - private Value( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.ByteString.Output unknownFieldsOutput = - com.google.protobuf.ByteString.newOutput(); - com.google.protobuf.CodedOutputStream unknownFieldsCodedOutput = - com.google.protobuf.CodedOutputStream.newInstance( - unknownFieldsOutput); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFieldsCodedOutput, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - valueTypeCase_ = 1; - valueType_ = bs; - break; - } - case 17: { - valueTypeCase_ = 2; - valueType_ = input.readDouble(); - break; - } - case 24: { - valueTypeCase_ = 3; - valueType_ = input.readUInt64(); - break; - } - case 32: { - valueTypeCase_ = 4; - valueType_ = input.readUInt64(); - break; - } - case 40: { - valueTypeCase_ = 5; - valueType_ = input.readBool(); - break; - } - case 50: { - com.google.protobuf.ByteString bs = input.readBytes(); - valueTypeCase_ = 6; - valueType_ = bs; - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - try { - unknownFieldsCodedOutput.flush(); - } catch (java.io.IOException e) { - // Should not happen - } finally { - unknownFields = unknownFieldsOutput.toByteString(); - } - makeExtensionsImmutable(); - } - } - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Value parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Value(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - private int valueTypeCase_ = 0; - private java.lang.Object valueType_; - public enum ValueTypeCase - implements com.google.protobuf.Internal.EnumLite { - STRING_VALUE(1), - DOUBLE_VALUE(2), - POS_INT_VALUE(3), - NEG_INT_VALUE(4), - BOOL_VALUE(5), - JSON_VALUE(6), - VALUETYPE_NOT_SET(0); - private int value = 0; - private ValueTypeCase(int value) { - this.value = value; - } - public static ValueTypeCase valueOf(int value) { - switch (value) { - case 1: return STRING_VALUE; - case 2: return DOUBLE_VALUE; - case 3: return POS_INT_VALUE; - case 4: return NEG_INT_VALUE; - case 5: return BOOL_VALUE; - case 6: return JSON_VALUE; - case 0: return VALUETYPE_NOT_SET; - default: throw new java.lang.IllegalArgumentException( - "Value is undefined for this oneof enum."); - } - } - public int getNumber() { - return this.value; - } - }; - - public ValueTypeCase - getValueTypeCase() { - return ValueTypeCase.valueOf( - valueTypeCase_); - } - - public static final int STRING_VALUE_FIELD_NUMBER = 1; - /** - * optional string string_value = 1; - */ - public boolean hasStringValue() { - return valueTypeCase_ == 1; - } - /** - * optional string string_value = 1; - */ - public java.lang.String getStringValue() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 1) { - ref = valueType_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8() && (valueTypeCase_ == 1)) { - valueType_ = s; - } - return s; - } - } - /** - * optional string string_value = 1; - */ - public com.google.protobuf.ByteString - getStringValueBytes() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 1) { - ref = valueType_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (valueTypeCase_ == 1) { - valueType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int DOUBLE_VALUE_FIELD_NUMBER = 2; - /** - * optional double double_value = 2; - */ - public boolean hasDoubleValue() { - return valueTypeCase_ == 2; - } - /** - * optional double double_value = 2; - */ - public double getDoubleValue() { - if (valueTypeCase_ == 2) { - return (java.lang.Double) valueType_; - } - return 0D; - } - - public static final int POS_INT_VALUE_FIELD_NUMBER = 3; - /** - * optional uint64 pos_int_value = 3; - */ - public boolean hasPosIntValue() { - return valueTypeCase_ == 3; - } - /** - * optional uint64 pos_int_value = 3; - */ - public long getPosIntValue() { - if (valueTypeCase_ == 3) { - return (java.lang.Long) valueType_; - } - return 0L; - } - - public static final int NEG_INT_VALUE_FIELD_NUMBER = 4; - /** - * optional uint64 neg_int_value = 4; - */ - public boolean hasNegIntValue() { - return valueTypeCase_ == 4; - } - /** - * optional uint64 neg_int_value = 4; - */ - public long getNegIntValue() { - if (valueTypeCase_ == 4) { - return (java.lang.Long) valueType_; - } - return 0L; - } - - public static final int BOOL_VALUE_FIELD_NUMBER = 5; - /** - * optional bool bool_value = 5; - */ - public boolean hasBoolValue() { - return valueTypeCase_ == 5; - } - /** - * optional bool bool_value = 5; - */ - public boolean getBoolValue() { - if (valueTypeCase_ == 5) { - return (java.lang.Boolean) valueType_; - } - return false; - } - - public static final int JSON_VALUE_FIELD_NUMBER = 6; - /** - * optional string json_value = 6; - */ - public boolean hasJsonValue() { - return valueTypeCase_ == 6; - } - /** - * optional string json_value = 6; - */ - public java.lang.String getJsonValue() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 6) { - ref = valueType_; - } - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8() && (valueTypeCase_ == 6)) { - valueType_ = s; - } - return s; - } - } - /** - * optional string json_value = 6; - */ - public com.google.protobuf.ByteString - getJsonValueBytes() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 6) { - ref = valueType_; - } - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (valueTypeCase_ == 6) { - valueType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (valueTypeCase_ == 1) { - output.writeBytes(1, getStringValueBytes()); - } - if (valueTypeCase_ == 2) { - output.writeDouble( - 2, (double)((java.lang.Double) valueType_)); - } - if (valueTypeCase_ == 3) { - output.writeUInt64( - 3, (long)((java.lang.Long) valueType_)); - } - if (valueTypeCase_ == 4) { - output.writeUInt64( - 4, (long)((java.lang.Long) valueType_)); - } - if (valueTypeCase_ == 5) { - output.writeBool( - 5, (boolean)((java.lang.Boolean) valueType_)); - } - if (valueTypeCase_ == 6) { - output.writeBytes(6, getJsonValueBytes()); - } - output.writeRawBytes(unknownFields); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (valueTypeCase_ == 1) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getStringValueBytes()); - } - if (valueTypeCase_ == 2) { - size += com.google.protobuf.CodedOutputStream - .computeDoubleSize( - 2, (double)((java.lang.Double) valueType_)); - } - if (valueTypeCase_ == 3) { - size += com.google.protobuf.CodedOutputStream - .computeUInt64Size( - 3, (long)((java.lang.Long) valueType_)); - } - if (valueTypeCase_ == 4) { - size += com.google.protobuf.CodedOutputStream - .computeUInt64Size( - 4, (long)((java.lang.Long) valueType_)); - } - if (valueTypeCase_ == 5) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize( - 5, (boolean)((java.lang.Boolean) valueType_)); - } - if (valueTypeCase_ == 6) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(6, getJsonValueBytes()); - } - size += unknownFields.size(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static Geobuf.Data.Value parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Value parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Value parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data.Value parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data.Value parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Value parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static Geobuf.Data.Value parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static Geobuf.Data.Value parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static Geobuf.Data.Value parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data.Value parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(Geobuf.Data.Value prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - /** - * Protobuf type {@code Data.Value} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - Geobuf.Data.Value, Builder> - implements - // @@protoc_insertion_point(builder_implements:Data.Value) - Geobuf.Data.ValueOrBuilder { - // Construct using Geobuf.Data.Value.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - valueTypeCase_ = 0; - valueType_ = null; - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public Geobuf.Data.Value getDefaultInstanceForType() { - return Geobuf.Data.Value.getDefaultInstance(); - } - - public Geobuf.Data.Value build() { - Geobuf.Data.Value result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Geobuf.Data.Value buildPartial() { - Geobuf.Data.Value result = new Geobuf.Data.Value(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (valueTypeCase_ == 1) { - result.valueType_ = valueType_; - } - if (valueTypeCase_ == 2) { - result.valueType_ = valueType_; - } - if (valueTypeCase_ == 3) { - result.valueType_ = valueType_; - } - if (valueTypeCase_ == 4) { - result.valueType_ = valueType_; - } - if (valueTypeCase_ == 5) { - result.valueType_ = valueType_; - } - if (valueTypeCase_ == 6) { - result.valueType_ = valueType_; - } - result.bitField0_ = to_bitField0_; - result.valueTypeCase_ = valueTypeCase_; - return result; - } - - public Builder mergeFrom(Geobuf.Data.Value other) { - if (other == Geobuf.Data.Value.getDefaultInstance()) return this; - switch (other.getValueTypeCase()) { - case STRING_VALUE: { - valueTypeCase_ = 1; - valueType_ = other.valueType_; - - break; - } - case DOUBLE_VALUE: { - setDoubleValue(other.getDoubleValue()); - break; - } - case POS_INT_VALUE: { - setPosIntValue(other.getPosIntValue()); - break; - } - case NEG_INT_VALUE: { - setNegIntValue(other.getNegIntValue()); - break; - } - case BOOL_VALUE: { - setBoolValue(other.getBoolValue()); - break; - } - case JSON_VALUE: { - valueTypeCase_ = 6; - valueType_ = other.valueType_; - - break; - } - case VALUETYPE_NOT_SET: { - break; - } - } - setUnknownFields( - getUnknownFields().concat(other.unknownFields)); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Geobuf.Data.Value parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Geobuf.Data.Value) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int valueTypeCase_ = 0; - private java.lang.Object valueType_; - public ValueTypeCase - getValueTypeCase() { - return ValueTypeCase.valueOf( - valueTypeCase_); - } - - public Builder clearValueType() { - valueTypeCase_ = 0; - valueType_ = null; - return this; - } - - private int bitField0_; - - /** - * optional string string_value = 1; - */ - public boolean hasStringValue() { - return valueTypeCase_ == 1; - } - /** - * optional string string_value = 1; - */ - public java.lang.String getStringValue() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 1) { - ref = valueType_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (valueTypeCase_ == 1) { - if (bs.isValidUtf8()) { - valueType_ = s; - } - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string string_value = 1; - */ - public com.google.protobuf.ByteString - getStringValueBytes() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 1) { - ref = valueType_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (valueTypeCase_ == 1) { - valueType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string string_value = 1; - */ - public Builder setStringValue( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - valueTypeCase_ = 1; - valueType_ = value; - - return this; - } - /** - * optional string string_value = 1; - */ - public Builder clearStringValue() { - if (valueTypeCase_ == 1) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - /** - * optional string string_value = 1; - */ - public Builder setStringValueBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - valueTypeCase_ = 1; - valueType_ = value; - - return this; - } - - /** - * optional double double_value = 2; - */ - public boolean hasDoubleValue() { - return valueTypeCase_ == 2; - } - /** - * optional double double_value = 2; - */ - public double getDoubleValue() { - if (valueTypeCase_ == 2) { - return (java.lang.Double) valueType_; - } - return 0D; - } - /** - * optional double double_value = 2; - */ - public Builder setDoubleValue(double value) { - valueTypeCase_ = 2; - valueType_ = value; - - return this; - } - /** - * optional double double_value = 2; - */ - public Builder clearDoubleValue() { - if (valueTypeCase_ == 2) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - - /** - * optional uint64 pos_int_value = 3; - */ - public boolean hasPosIntValue() { - return valueTypeCase_ == 3; - } - /** - * optional uint64 pos_int_value = 3; - */ - public long getPosIntValue() { - if (valueTypeCase_ == 3) { - return (java.lang.Long) valueType_; - } - return 0L; - } - /** - * optional uint64 pos_int_value = 3; - */ - public Builder setPosIntValue(long value) { - valueTypeCase_ = 3; - valueType_ = value; - - return this; - } - /** - * optional uint64 pos_int_value = 3; - */ - public Builder clearPosIntValue() { - if (valueTypeCase_ == 3) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - - /** - * optional uint64 neg_int_value = 4; - */ - public boolean hasNegIntValue() { - return valueTypeCase_ == 4; - } - /** - * optional uint64 neg_int_value = 4; - */ - public long getNegIntValue() { - if (valueTypeCase_ == 4) { - return (java.lang.Long) valueType_; - } - return 0L; - } - /** - * optional uint64 neg_int_value = 4; - */ - public Builder setNegIntValue(long value) { - valueTypeCase_ = 4; - valueType_ = value; - - return this; - } - /** - * optional uint64 neg_int_value = 4; - */ - public Builder clearNegIntValue() { - if (valueTypeCase_ == 4) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - - /** - * optional bool bool_value = 5; - */ - public boolean hasBoolValue() { - return valueTypeCase_ == 5; - } - /** - * optional bool bool_value = 5; - */ - public boolean getBoolValue() { - if (valueTypeCase_ == 5) { - return (java.lang.Boolean) valueType_; - } - return false; - } - /** - * optional bool bool_value = 5; - */ - public Builder setBoolValue(boolean value) { - valueTypeCase_ = 5; - valueType_ = value; - - return this; - } - /** - * optional bool bool_value = 5; - */ - public Builder clearBoolValue() { - if (valueTypeCase_ == 5) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - - /** - * optional string json_value = 6; - */ - public boolean hasJsonValue() { - return valueTypeCase_ == 6; - } - /** - * optional string json_value = 6; - */ - public java.lang.String getJsonValue() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 6) { - ref = valueType_; - } - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (valueTypeCase_ == 6) { - if (bs.isValidUtf8()) { - valueType_ = s; - } - } - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string json_value = 6; - */ - public com.google.protobuf.ByteString - getJsonValueBytes() { - java.lang.Object ref = ""; - if (valueTypeCase_ == 6) { - ref = valueType_; - } - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - if (valueTypeCase_ == 6) { - valueType_ = b; - } - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string json_value = 6; - */ - public Builder setJsonValue( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - valueTypeCase_ = 6; - valueType_ = value; - - return this; - } - /** - * optional string json_value = 6; - */ - public Builder clearJsonValue() { - if (valueTypeCase_ == 6) { - valueTypeCase_ = 0; - valueType_ = null; - - } - return this; - } - /** - * optional string json_value = 6; - */ - public Builder setJsonValueBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - valueTypeCase_ = 6; - valueType_ = value; - - return this; - } - - // @@protoc_insertion_point(builder_scope:Data.Value) - } - - static { - defaultInstance = new Value(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:Data.Value) - } - - private int bitField0_; - private int dataTypeCase_ = 0; - private java.lang.Object dataType_; - public enum DataTypeCase - implements com.google.protobuf.Internal.EnumLite { - FEATURE_COLLECTION(4), - FEATURE(5), - GEOMETRY(6), - DATATYPE_NOT_SET(0); - private int value = 0; - private DataTypeCase(int value) { - this.value = value; - } - public static DataTypeCase valueOf(int value) { - switch (value) { - case 4: return FEATURE_COLLECTION; - case 5: return FEATURE; - case 6: return GEOMETRY; - case 0: return DATATYPE_NOT_SET; - default: throw new java.lang.IllegalArgumentException( - "Value is undefined for this oneof enum."); - } - } - public int getNumber() { - return this.value; - } - }; - - public DataTypeCase - getDataTypeCase() { - return DataTypeCase.valueOf( - dataTypeCase_); - } - - public static final int KEYS_FIELD_NUMBER = 1; - private com.google.protobuf.LazyStringList keys_; - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - public com.google.protobuf.ProtocolStringList - getKeysList() { - return keys_; - } - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - public int getKeysCount() { - return keys_.size(); - } - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - public java.lang.String getKeys(int index) { - return keys_.get(index); - } - /** - * repeated string keys = 1; - * - *
-     * global arrays of unique keys
-     * 
- */ - public com.google.protobuf.ByteString - getKeysBytes(int index) { - return keys_.getByteString(index); - } - - public static final int DIMENSIONS_FIELD_NUMBER = 2; - private int dimensions_; - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-     * max coordinate dimensions
-     * 
- */ - public boolean hasDimensions() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-     * max coordinate dimensions
-     * 
- */ - public int getDimensions() { - return dimensions_; - } - - public static final int PRECISION_FIELD_NUMBER = 3; - private int precision_; - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-     * number of digits after decimal point for coordinates
-     * 
- */ - public boolean hasPrecision() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-     * number of digits after decimal point for coordinates
-     * 
- */ - public int getPrecision() { - return precision_; - } - - public static final int FEATURE_COLLECTION_FIELD_NUMBER = 4; - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public boolean hasFeatureCollection() { - return dataTypeCase_ == 4; - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Geobuf.Data.FeatureCollection getFeatureCollection() { - if (dataTypeCase_ == 4) { - return (Geobuf.Data.FeatureCollection) dataType_; - } - return Geobuf.Data.FeatureCollection.getDefaultInstance(); - } - - public static final int FEATURE_FIELD_NUMBER = 5; - /** - * optional .Data.Feature feature = 5; - */ - public boolean hasFeature() { - return dataTypeCase_ == 5; - } - /** - * optional .Data.Feature feature = 5; - */ - public Geobuf.Data.Feature getFeature() { - if (dataTypeCase_ == 5) { - return (Geobuf.Data.Feature) dataType_; - } - return Geobuf.Data.Feature.getDefaultInstance(); - } - - public static final int GEOMETRY_FIELD_NUMBER = 6; - /** - * optional .Data.Geometry geometry = 6; - */ - public boolean hasGeometry() { - return dataTypeCase_ == 6; - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Geobuf.Data.Geometry getGeometry() { - if (dataTypeCase_ == 6) { - return (Geobuf.Data.Geometry) dataType_; - } - return Geobuf.Data.Geometry.getDefaultInstance(); - } - - private void initFields() { - keys_ = com.google.protobuf.LazyStringArrayList.EMPTY; - dimensions_ = 2; - precision_ = 6; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (hasFeatureCollection()) { - if (!getFeatureCollection().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - if (hasFeature()) { - if (!getFeature().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - if (hasGeometry()) { - if (!getGeometry().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < keys_.size(); i++) { - output.writeBytes(1, keys_.getByteString(i)); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeUInt32(2, dimensions_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeUInt32(3, precision_); - } - if (dataTypeCase_ == 4) { - output.writeMessage(4, (Geobuf.Data.FeatureCollection) dataType_); - } - if (dataTypeCase_ == 5) { - output.writeMessage(5, (Geobuf.Data.Feature) dataType_); - } - if (dataTypeCase_ == 6) { - output.writeMessage(6, (Geobuf.Data.Geometry) dataType_); - } - output.writeRawBytes(unknownFields); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - { - int dataSize = 0; - for (int i = 0; i < keys_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(keys_.getByteString(i)); - } - size += dataSize; - size += 1 * getKeysList().size(); - } - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(2, dimensions_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(3, precision_); - } - if (dataTypeCase_ == 4) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(4, (Geobuf.Data.FeatureCollection) dataType_); - } - if (dataTypeCase_ == 5) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, (Geobuf.Data.Feature) dataType_); - } - if (dataTypeCase_ == 6) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, (Geobuf.Data.Geometry) dataType_); - } - size += unknownFields.size(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static Geobuf.Data parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static Geobuf.Data parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static Geobuf.Data parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static Geobuf.Data parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static Geobuf.Data parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static Geobuf.Data parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static Geobuf.Data parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(Geobuf.Data prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - /** - * Protobuf type {@code Data} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageLite.Builder< - Geobuf.Data, Builder> - implements - // @@protoc_insertion_point(builder_implements:Data) - Geobuf.DataOrBuilder { - // Construct using Geobuf.Data.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private void maybeForceBuilderInitialization() { - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - keys_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - dimensions_ = 2; - bitField0_ = (bitField0_ & ~0x00000002); - precision_ = 6; - bitField0_ = (bitField0_ & ~0x00000004); - dataTypeCase_ = 0; - dataType_ = null; - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public Geobuf.Data getDefaultInstanceForType() { - return Geobuf.Data.getDefaultInstance(); - } - - public Geobuf.Data build() { - Geobuf.Data result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public Geobuf.Data buildPartial() { - Geobuf.Data result = new Geobuf.Data(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - keys_ = keys_.getUnmodifiableView(); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.keys_ = keys_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000001; - } - result.dimensions_ = dimensions_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000002; - } - result.precision_ = precision_; - if (dataTypeCase_ == 4) { - result.dataType_ = dataType_; - } - if (dataTypeCase_ == 5) { - result.dataType_ = dataType_; - } - if (dataTypeCase_ == 6) { - result.dataType_ = dataType_; - } - result.bitField0_ = to_bitField0_; - result.dataTypeCase_ = dataTypeCase_; - return result; - } - - public Builder mergeFrom(Geobuf.Data other) { - if (other == Geobuf.Data.getDefaultInstance()) return this; - if (!other.keys_.isEmpty()) { - if (keys_.isEmpty()) { - keys_ = other.keys_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureKeysIsMutable(); - keys_.addAll(other.keys_); - } - - } - if (other.hasDimensions()) { - setDimensions(other.getDimensions()); - } - if (other.hasPrecision()) { - setPrecision(other.getPrecision()); - } - switch (other.getDataTypeCase()) { - case FEATURE_COLLECTION: { - mergeFeatureCollection(other.getFeatureCollection()); - break; - } - case FEATURE: { - mergeFeature(other.getFeature()); - break; - } - case GEOMETRY: { - mergeGeometry(other.getGeometry()); - break; - } - case DATATYPE_NOT_SET: { - break; - } - } - setUnknownFields( - getUnknownFields().concat(other.unknownFields)); - return this; - } - - public final boolean isInitialized() { - if (hasFeatureCollection()) { - if (!getFeatureCollection().isInitialized()) { - - return false; - } - } - if (hasFeature()) { - if (!getFeature().isInitialized()) { - - return false; - } - } - if (hasGeometry()) { - if (!getGeometry().isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Geobuf.Data parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (Geobuf.Data) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int dataTypeCase_ = 0; - private java.lang.Object dataType_; - public DataTypeCase - getDataTypeCase() { - return DataTypeCase.valueOf( - dataTypeCase_); - } - - public Builder clearDataType() { - dataTypeCase_ = 0; - dataType_ = null; - return this; - } - - private int bitField0_; - - private com.google.protobuf.LazyStringList keys_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureKeysIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - keys_ = new com.google.protobuf.LazyStringArrayList(keys_); - bitField0_ |= 0x00000001; - } - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public com.google.protobuf.ProtocolStringList - getKeysList() { - return keys_.getUnmodifiableView(); - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public int getKeysCount() { - return keys_.size(); - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public java.lang.String getKeys(int index) { - return keys_.get(index); - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public com.google.protobuf.ByteString - getKeysBytes(int index) { - return keys_.getByteString(index); - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public Builder setKeys( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.set(index, value); - - return this; - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public Builder addKeys( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.add(value); - - return this; - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public Builder addAllKeys( - java.lang.Iterable values) { - ensureKeysIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, keys_); - - return this; - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public Builder clearKeys() { - keys_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000001); - - return this; - } - /** - * repeated string keys = 1; - * - *
-       * global arrays of unique keys
-       * 
- */ - public Builder addKeysBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureKeysIsMutable(); - keys_.add(value); - - return this; - } - - private int dimensions_ = 2; - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-       * max coordinate dimensions
-       * 
- */ - public boolean hasDimensions() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-       * max coordinate dimensions
-       * 
- */ - public int getDimensions() { - return dimensions_; - } - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-       * max coordinate dimensions
-       * 
- */ - public Builder setDimensions(int value) { - bitField0_ |= 0x00000002; - dimensions_ = value; - - return this; - } - /** - * optional uint32 dimensions = 2 [default = 2]; - * - *
-       * max coordinate dimensions
-       * 
- */ - public Builder clearDimensions() { - bitField0_ = (bitField0_ & ~0x00000002); - dimensions_ = 2; - - return this; - } - - private int precision_ = 6; - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-       * number of digits after decimal point for coordinates
-       * 
- */ - public boolean hasPrecision() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-       * number of digits after decimal point for coordinates
-       * 
- */ - public int getPrecision() { - return precision_; - } - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-       * number of digits after decimal point for coordinates
-       * 
- */ - public Builder setPrecision(int value) { - bitField0_ |= 0x00000004; - precision_ = value; - - return this; - } - /** - * optional uint32 precision = 3 [default = 6]; - * - *
-       * number of digits after decimal point for coordinates
-       * 
- */ - public Builder clearPrecision() { - bitField0_ = (bitField0_ & ~0x00000004); - precision_ = 6; - - return this; - } - - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public boolean hasFeatureCollection() { - return dataTypeCase_ == 4; - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Geobuf.Data.FeatureCollection getFeatureCollection() { - if (dataTypeCase_ == 4) { - return (Geobuf.Data.FeatureCollection) dataType_; - } - return Geobuf.Data.FeatureCollection.getDefaultInstance(); - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Builder setFeatureCollection(Geobuf.Data.FeatureCollection value) { - if (value == null) { - throw new NullPointerException(); - } - dataType_ = value; - - dataTypeCase_ = 4; - return this; - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Builder setFeatureCollection( - Geobuf.Data.FeatureCollection.Builder builderForValue) { - dataType_ = builderForValue.build(); - - dataTypeCase_ = 4; - return this; - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Builder mergeFeatureCollection(Geobuf.Data.FeatureCollection value) { - if (dataTypeCase_ == 4 && - dataType_ != Geobuf.Data.FeatureCollection.getDefaultInstance()) { - dataType_ = Geobuf.Data.FeatureCollection.newBuilder((Geobuf.Data.FeatureCollection) dataType_) - .mergeFrom(value).buildPartial(); - } else { - dataType_ = value; - } - - dataTypeCase_ = 4; - return this; - } - /** - * optional .Data.FeatureCollection feature_collection = 4; - */ - public Builder clearFeatureCollection() { - if (dataTypeCase_ == 4) { - dataTypeCase_ = 0; - dataType_ = null; - - } - return this; - } - - /** - * optional .Data.Feature feature = 5; - */ - public boolean hasFeature() { - return dataTypeCase_ == 5; - } - /** - * optional .Data.Feature feature = 5; - */ - public Geobuf.Data.Feature getFeature() { - if (dataTypeCase_ == 5) { - return (Geobuf.Data.Feature) dataType_; - } - return Geobuf.Data.Feature.getDefaultInstance(); - } - /** - * optional .Data.Feature feature = 5; - */ - public Builder setFeature(Geobuf.Data.Feature value) { - if (value == null) { - throw new NullPointerException(); - } - dataType_ = value; - - dataTypeCase_ = 5; - return this; - } - /** - * optional .Data.Feature feature = 5; - */ - public Builder setFeature( - Geobuf.Data.Feature.Builder builderForValue) { - dataType_ = builderForValue.build(); - - dataTypeCase_ = 5; - return this; - } - /** - * optional .Data.Feature feature = 5; - */ - public Builder mergeFeature(Geobuf.Data.Feature value) { - if (dataTypeCase_ == 5 && - dataType_ != Geobuf.Data.Feature.getDefaultInstance()) { - dataType_ = Geobuf.Data.Feature.newBuilder((Geobuf.Data.Feature) dataType_) - .mergeFrom(value).buildPartial(); - } else { - dataType_ = value; - } - - dataTypeCase_ = 5; - return this; - } - /** - * optional .Data.Feature feature = 5; - */ - public Builder clearFeature() { - if (dataTypeCase_ == 5) { - dataTypeCase_ = 0; - dataType_ = null; - - } - return this; - } - - /** - * optional .Data.Geometry geometry = 6; - */ - public boolean hasGeometry() { - return dataTypeCase_ == 6; - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Geobuf.Data.Geometry getGeometry() { - if (dataTypeCase_ == 6) { - return (Geobuf.Data.Geometry) dataType_; - } - return Geobuf.Data.Geometry.getDefaultInstance(); - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Builder setGeometry(Geobuf.Data.Geometry value) { - if (value == null) { - throw new NullPointerException(); - } - dataType_ = value; - - dataTypeCase_ = 6; - return this; - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Builder setGeometry( - Geobuf.Data.Geometry.Builder builderForValue) { - dataType_ = builderForValue.build(); - - dataTypeCase_ = 6; - return this; - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Builder mergeGeometry(Geobuf.Data.Geometry value) { - if (dataTypeCase_ == 6 && - dataType_ != Geobuf.Data.Geometry.getDefaultInstance()) { - dataType_ = Geobuf.Data.Geometry.newBuilder((Geobuf.Data.Geometry) dataType_) - .mergeFrom(value).buildPartial(); - } else { - dataType_ = value; - } - - dataTypeCase_ = 6; - return this; - } - /** - * optional .Data.Geometry geometry = 6; - */ - public Builder clearGeometry() { - if (dataTypeCase_ == 6) { - dataTypeCase_ = 0; - dataType_ = null; - - } - return this; - } - - // @@protoc_insertion_point(builder_scope:Data) - } - - static { - defaultInstance = new Data(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:Data) - } - - - static { - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/src/test/java/com/conveyal/data/census/IntegrationTest.java b/src/test/java/com/conveyal/data/census/IntegrationTest.java deleted file mode 100644 index 0b0429d..0000000 --- a/src/test/java/com/conveyal/data/census/IntegrationTest.java +++ /dev/null @@ -1,242 +0,0 @@ -package com.conveyal.data.census; - -import com.conveyal.data.geobuf.GeobufDecoder; -import com.conveyal.data.geobuf.GeobufFeature; -import com.csvreader.CsvReader; -import com.google.common.io.ByteStreams; -import com.google.common.io.Files; -import org.locationtech.jts.geom.Envelope; -import gnu.trove.map.TLongObjectMap; -import gnu.trove.map.hash.TLongObjectHashMap; -import junit.framework.TestCase; -import org.junit.Test; - -import java.io.*; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.zip.GZIPInputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -/** - * Test loading, extracting, etc. - */ -public class IntegrationTest extends TestCase { - private CsvReader reader; - private TLongObjectMap features; - - /** test loading and extracting from a small state (DC) */ - @Test - public void testAll () throws Exception { - // extract the data - // note that the LODES data is fake; we replaced every value with a unique number to ensure that we detect - // swapped/incorrect column names; some columns are collinear in the original DC dataset (i.e. all zeros) - // so they wouldn't show up in tests if we swapped them. - // The python script in the resources directory alongside the data file takes a LODES CSV and replaces all the - // values in it with unique numbers. - File dir = Files.createTempDir(); - ZipInputStream zis = new ZipInputStream(getClass().getResourceAsStream("integrationTest.zip")); - - ZipEntry entry; - while ((entry = zis.getNextEntry()) != null) { - if (entry.isDirectory()) - continue; - - File out = new File(dir, entry.getName()); - out.getParentFile().mkdirs(); - FileOutputStream fos = new FileOutputStream(out); - ByteStreams.copy(zis, fos); - fos.close(); - } - - // load up the data - CensusLoader.main(dir.getAbsolutePath()); - - // do an extract (this crosses a tile boundary) - CensusExtractor.main(new File(dir, "tiles").getAbsolutePath(), "38.9872", "-77.0378", "38.9218", "-77.1086", new File(dir, "extract.pbf").getAbsolutePath()); - - // load the extract - FileInputStream fis = new FileInputStream(new File(dir, "extract.pbf")); - GeobufDecoder decoder = new GeobufDecoder(fis); - - assertTrue(decoder.hasNext()); - - Envelope envelope = new Envelope(-77.1086, -77.0378, 38.9218, 38.9872); - - features = new TLongObjectHashMap<>(); - - while (decoder.hasNext()) { - GeobufFeature feat = decoder.next(); - // TODO the extractor has a true geometric overlap check, not just an envelope check - // so this check could be made more specific - assertTrue(feat.geometry.getEnvelopeInternal().intersects(envelope)); - - features.put(feat.numericId, feat); - assertNotSame(0, feat.numericId); - } - - // > 1 to ensure all numeric IDs are not the same - assertTrue(features.size() > 1); - // random census block in NW DC - assertTrue(features.containsKey(110010014023009L)); - - // read the workplace area characteristics csv - InputStream csv = new GZIPInputStream(new FileInputStream(new File(new File(dir, "jobs"), "dc_wac_S000_JT00_2013.csv.gz"))); - reader = new CsvReader(new InputStreamReader(csv)); - reader.readHeaders(); - - // make sure we found a jobs entry - boolean foundJobsEntry = false; - - String[] line; - while (reader.readRecord()) { - // make sure everything matches, and that we got the column name mappings correct - foundJobsEntry = foundJobsEntry || check("Jobs at firms aged 0-1 years", "CFA01"); - check("Jobs at firms aged 2-3 years", "CFA02"); - check("Jobs at firms aged 4-5 years", "CFA03"); - check("Jobs at firms aged 6-10 years", "CFA04"); - check("Jobs at firms aged 11 or more years", "CFA05"); - - check("Jobs at firms with 0-19 employees", "CFS01"); - check("Jobs at firms with 20-49 employees", "CFS02"); - check("Jobs at firms with 50-249 employees", "CFS03"); - check("Jobs at firms with 250-499 employees", "CFS04"); - check("Jobs at firms with 500 or more employees", "CFS05"); - - check("Jobs employing Hispanic or Latino workers", "CT02"); - check("Jobs employing not Hispanic or Latino workers", "CT01"); - - check("Jobs employing females", "CS02"); - check("Jobs employing males", "CS01"); - - check("Jobs employing workers age 29 or younger", "CA01"); - check("Jobs employing workers age 30 to 54", "CA02"); - check("Jobs employing workers age 55 or older", "CA03"); - - check("Jobs employing workers with less than high school education", "CD01"); - check("Jobs employing workers with high school education, no college", "CD02"); - check("Jobs employing workers with some college education or Associate degree", "CD03"); - check("Jobs employing workers with Bachelor's degree or higher", "CD04"); - - check("Jobs employing workers with race American Indian or Alaska Native alone", "CR03"); - check("Jobs employing workers with race Asian alone", "CR04"); - check("Jobs employing workers with race Black or African American alone", "CR02"); - check("Jobs employing workers with race Native Hawaiian or Other Pacific Islander alone", "CR05"); - check("Jobs employing workers with race White alone", "CR01"); - check("Jobs employing workers with two or more racial groups", "CR07"); - - check("Jobs in accommodation and food services", "CNS18"); - check("Jobs in administration, support, and waste management", "CNS14"); - check("Jobs in agriculture, forestry, fishing and hunting", "CNS01"); - check("Jobs in arts, entertainment and recreation", "CNS17"); - check("Jobs in construction", "CNS04"); - check("Jobs in educational services", "CNS15"); - check("Jobs in finance and insurance", "CNS10"); - check("Jobs in healthcare and social assistance", "CNS16"); - check("Jobs in information", "CNS09"); - check("Jobs in management", "CNS13"); - check("Jobs in manufacturing", "CNS05"); - check("Jobs in mining, quarrying, and oil and gas extraction", "CNS02"); - check("Jobs in other services, except public administration", "CNS19"); - check("Jobs in professional, scientific and technical services", "CNS12"); - check("Jobs in public administration", "CNS20"); - check("Jobs in real estate", "CNS11"); - check("Jobs in retail trade", "CNS07"); - check("Jobs in transportation and warehousing", "CNS08"); - check("Jobs in utilities", "CNS03"); - check("Jobs in wholesale trade", "CNS06"); - - check("Jobs total", "C000"); - - check("Jobs with earnings $1250 per month or less", "CE01"); - check("Jobs with earnings $1251 - $3333 per month", "CE02"); - check("Jobs with earnings greater than $3333 per month", "CE03"); - } - csv.close(); - - assertTrue(foundJobsEntry); - - // read the rac csv - csv = new GZIPInputStream(new FileInputStream(new File(new File(dir, "workforce"), "dc_rac_S000_JT00_2013.csv.gz"))); - reader = new CsvReader(new InputStreamReader(csv)); - - reader.readHeaders(); - - boolean foundWorkforceEntry = false; - - while (reader.readRecord()) { - foundWorkforceEntry = foundWorkforceEntry || check("Workers age 29 or younger", "CA01"); - check("Workers age 30 to 54", "CA02"); - check("Workers age 55 or older", "CA03"); - - check("Workers in accommodation and food services", "CNS18"); - check("Workers in administration, support, and waste management", "CNS14"); - check("Workers in agriculture, forestry, fishing and hunting", "CNS01"); - check("Workers in arts, entertainment and recreation", "CNS17"); - check("Workers in construction", "CNS04"); - check("Workers in educational services", "CNS15"); - check("Workers in finance and insurance", "CNS10"); - check("Workers in healthcare and social assistance", "CNS16"); - check("Workers in information", "CNS09"); - check("Workers in management", "CNS13"); - check("Workers in manufacturing", "CNS05"); - check("Workers in mining, quarrying, and oil and gas extraction", "CNS02"); - check("Workers in other services, except public administration", "CNS19"); - check("Workers in professional, scientific and technical services", "CNS12"); - check("Workers in public administration", "CNS20"); - check("Workers in real estate", "CNS11"); - check("Workers in retail trade", "CNS07"); - check("Workers in transportation and warehousing", "CNS08"); - check("Workers in utilities", "CNS03"); - check("Workers in wholesale trade", "CNS06"); - - check("Workers total", "C000"); - - check("Workers with earnings $1250 per month or less", "CE01"); - check("Workers with earnings $1251 - $3333 per month", "CE02"); - check("Workers with earnings greater than $3333 per month", "CE03"); - - check("Workers with less than high school education", "CD01"); - check("Workers with high school education, no college", "CD02"); - check("Workers with some college education or Associate degree", "CD03"); - check("Workers with Bachelor's degree or higher", "CD04"); - - check("Workers with race American Indian or Alaska Native alone", "CR03"); - check("Workers with race Asian alone", "CR04"); - check("Workers with race Black or African American alone", "CR02"); - check("Workers with race Native Hawaiian or Other Pacific Islander alone", "CR05"); - check("Workers with race White alone", "CR01"); - check("Workers with two or more racial groups", "CR07"); - - check("Workers, Hispanic or Latino", "CT02"); - check("Workers, not Hispanic or Latino", "CT01"); - - check("Workers, female", "CS02"); - check("Workers, male", "CS01"); - } - csv.close(); - - assertTrue(foundWorkforceEntry); - dir.delete(); - } - - private boolean check (String colName, String colCode) throws Exception { - long fid; - - // TODO cache? - Set headers = new HashSet<>(Arrays.asList(reader.getHeaders())); - - if (headers.contains("w_geocode")) - fid = Long.parseLong(reader.get("w_geocode")); - else - fid = Long.parseLong(reader.get("h_geocode")); - - // cast to primitive long so as not to confuse Java's type inference - if (features.containsKey(fid)) { - assertEquals((long) Long.parseLong(reader.get(colCode)), (long) features.get(fid).properties.get(colName)); - return true; - } - else return false; - } -} diff --git a/src/test/resources/com/conveyal/data/census/integrationTest.zip b/src/test/resources/com/conveyal/data/census/integrationTest.zip deleted file mode 100644 index 9b9ea2f..0000000 Binary files a/src/test/resources/com/conveyal/data/census/integrationTest.zip and /dev/null differ