Skip to content

Commit

Permalink
Attach parquet schema to features (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry authored May 26, 2024
1 parent fb22392 commit eca7e53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.onthegomap.planetiler.geo.GeometryException;
import com.onthegomap.planetiler.reader.SourceFeature;
import com.onthegomap.planetiler.reader.Struct;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import org.apache.parquet.schema.MessageType;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Lineal;
import org.locationtech.jts.geom.Polygonal;
Expand All @@ -18,15 +20,29 @@ public class ParquetFeature extends SourceFeature {

private final GeometryReader geometryParser;
private final Object rawGeometry;
private final Path path;
private final MessageType schema;
private Geometry latLon;
private Geometry world;
private Struct struct = null;

ParquetFeature(String source, String sourceLayer, long id, GeometryReader geometryParser,
Map<String, Object> tags) {
Map<String, Object> tags, Path path, MessageType schema) {
super(tags, source, sourceLayer, List.of(), id);
this.geometryParser = geometryParser;
this.rawGeometry = tags.remove(geometryParser.geometryColumn);
this.path = path;
this.schema = schema;
}

/** Returns the parquet file that this feature was read from. */
public Path path() {
return path;
}

/** Returns the {@link MessageType} schema of the parquet file that this feature was read from. */
public MessageType parquetSchema() {
return schema;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public ParquetFeature next() {
idGenerator != null ? idGenerator.applyAsLong(item) :
Hashing.fnv1a64(blockHash, ByteBuffer.allocate(8).putLong(i).array()),
geometryReader,
item
item,
path,
schema
);

if (postFilterBounds != null) {
Expand Down

0 comments on commit eca7e53

Please sign in to comment.