-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable the export of vector tiles in the PMTiles format. Most of the necessary functions have been ported from [go-pmtiles](https://github.com/protomaps/go-pmtiles) to Java.
- Loading branch information
Showing
33 changed files
with
1,896 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="basemap-export-mbtiles" type="Application" factoryName="Application"> | ||
<option name="MAIN_CLASS_NAME" value="org.apache.baremaps.cli.Baremaps" /> | ||
<module name="baremaps-cli" /> | ||
<option name="PROGRAM_PARAMETERS" value="map export --tileset tileset.js --repository tiles.mbtiles --format mbtiles" /> | ||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/basemap" /> | ||
<method v="2"> | ||
<option name="Make" enabled="true" /> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="basemap-export-pmtiles" type="Application" factoryName="Application"> | ||
<option name="MAIN_CLASS_NAME" value="org.apache.baremaps.cli.Baremaps" /> | ||
<module name="baremaps-cli" /> | ||
<option name="PROGRAM_PARAMETERS" value="map export --tileset tileset.js --repository tiles.mbtiles --format pmtiles" /> | ||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/basemap" /> | ||
<method v="2"> | ||
<option name="Make" enabled="true" /> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Compression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.baremaps.tilestore.pmtiles; | ||
|
||
import java.io.*; | ||
import java.util.zip.GZIPInputStream; | ||
import java.util.zip.GZIPOutputStream; | ||
|
||
enum Compression { | ||
Unknown, | ||
None, | ||
Gzip, | ||
Brotli, | ||
Zstd; | ||
|
||
InputStream decompress(InputStream inputStream) throws IOException { | ||
return switch (this) { | ||
case None -> inputStream; | ||
case Gzip -> decompressGzip(inputStream); | ||
case Brotli -> decompressBrotli(inputStream); | ||
case Zstd -> decompressZstd(inputStream); | ||
default -> throw new RuntimeException("Unknown compression"); | ||
}; | ||
} | ||
|
||
static InputStream decompressGzip(InputStream inputStream) throws IOException { | ||
return new GZIPInputStream(inputStream); | ||
} | ||
|
||
static InputStream decompressBrotli(InputStream buffer) { | ||
throw new RuntimeException("Brotli compression not implemented"); | ||
} | ||
|
||
static InputStream decompressZstd(InputStream buffer) { | ||
throw new RuntimeException("Zstd compression not implemented"); | ||
} | ||
|
||
OutputStream compress(OutputStream outputStream) throws IOException { | ||
return switch (this) { | ||
case None -> outputStream; | ||
case Gzip -> compressGzip(outputStream); | ||
case Brotli -> compressBrotli(outputStream); | ||
case Zstd -> compressZstd(outputStream); | ||
default -> throw new RuntimeException("Unknown compression"); | ||
}; | ||
} | ||
|
||
static OutputStream compressGzip(OutputStream outputStream) throws IOException { | ||
return new GZIPOutputStream(outputStream); | ||
} | ||
|
||
static OutputStream compressBrotli(OutputStream outputStream) { | ||
throw new RuntimeException("Brotli compression not implemented"); | ||
} | ||
|
||
static OutputStream compressZstd(OutputStream outputStream) { | ||
throw new RuntimeException("Zstd compression not implemented"); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Directories.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.baremaps.tilestore.pmtiles; | ||
|
||
class Directories { | ||
|
||
private final byte[] root; | ||
private final byte[] leaves; | ||
private final int numLeaves; | ||
|
||
public Directories(byte[] root, byte[] leaves, int numLeaves) { | ||
this.root = root; | ||
this.leaves = leaves; | ||
this.numLeaves = numLeaves; | ||
} | ||
|
||
public byte[] getRoot() { | ||
return root; | ||
} | ||
|
||
public byte[] getLeaves() { | ||
return leaves; | ||
} | ||
|
||
public int getNumLeaves() { | ||
return numLeaves; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
baremaps-core/src/main/java/org/apache/baremaps/tilestore/pmtiles/Entry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.baremaps.tilestore.pmtiles; | ||
|
||
class Entry { | ||
private long tileId; | ||
private long offset; | ||
private long length; | ||
private long runLength; | ||
|
||
public Entry() {} | ||
|
||
public Entry(long tileId, long offset, long length, long runLength) { | ||
this.tileId = tileId; | ||
this.offset = offset; | ||
this.length = length; | ||
this.runLength = runLength; | ||
} | ||
|
||
public long getTileId() { | ||
return tileId; | ||
} | ||
|
||
public void setTileId(long tileId) { | ||
this.tileId = tileId; | ||
} | ||
|
||
public long getOffset() { | ||
return offset; | ||
} | ||
|
||
public void setOffset(long offset) { | ||
this.offset = offset; | ||
} | ||
|
||
public long getLength() { | ||
return length; | ||
} | ||
|
||
public void setLength(long length) { | ||
this.length = length; | ||
} | ||
|
||
public long getRunLength() { | ||
return runLength; | ||
} | ||
|
||
public void setRunLength(long runLength) { | ||
this.runLength = runLength; | ||
} | ||
} |
Oops, something went wrong.