Search in sources :

Example 1 with OsmEntity

use of de.topobyte.osm4j.core.model.iface.OsmEntity in project osm4j-pbf by topobyte.

the class PbfWriter method addTagsToStringTable.

private void addTagsToStringTable(Collection<? extends OsmEntity> entities) {
    for (OsmEntity entity : entities) {
        for (int k = 0; k < entity.getNumberOfTags(); k++) {
            OsmTag tag = entity.getTag(k);
            stringTable.incr(tag.getKey());
            stringTable.incr(tag.getValue());
        }
    }
}
Also used : OsmEntity(de.topobyte.osm4j.core.model.iface.OsmEntity) OsmTag(de.topobyte.osm4j.core.model.iface.OsmTag)

Example 2 with OsmEntity

use of de.topobyte.osm4j.core.model.iface.OsmEntity in project osm4j-pbf by topobyte.

the class PbfWriter method addUsersToStringTable.

private void addUsersToStringTable(Collection<? extends OsmEntity> entities) {
    for (OsmEntity entity : entities) {
        OsmMetadata metadata = entity.getMetadata();
        if (metadata == null) {
            continue;
        }
        String user = metadata.getUser();
        if (user == null) {
            continue;
        }
        stringTable.incr(user);
    }
}
Also used : OsmEntity(de.topobyte.osm4j.core.model.iface.OsmEntity) OsmMetadata(de.topobyte.osm4j.core.model.iface.OsmMetadata) ByteString(com.google.protobuf.ByteString)

Example 3 with OsmEntity

use of de.topobyte.osm4j.core.model.iface.OsmEntity in project osm4j-pbf by topobyte.

the class PbfWriter method serializeMetadataDense.

private void serializeMetadataDense(Osmformat.DenseInfo.Builder b, Collection<? extends OsmEntity> entities) {
    long lasttimestamp = 0, lastchangeset = 0;
    int lastuserSid = 0, lastuid = 0;
    for (OsmEntity e : entities) {
        OsmMetadata metadata = e.getMetadata();
        if (metadata == null) {
            metadata = new Metadata(-1, -1, -1, "", -1);
        }
        int uid = (int) metadata.getUid();
        int userSid = stringTable.getIndex(metadata.getUser());
        int timestamp = (int) (metadata.getTimestamp() / dateGranularity);
        int version = metadata.getVersion();
        long changeset = metadata.getChangeset();
        b.addVersion(version);
        b.addTimestamp(timestamp - lasttimestamp);
        lasttimestamp = timestamp;
        b.addChangeset(changeset - lastchangeset);
        lastchangeset = changeset;
        b.addUid(uid - lastuid);
        lastuid = uid;
        b.addUserSid(userSid - lastuserSid);
        lastuserSid = userSid;
    }
}
Also used : OsmEntity(de.topobyte.osm4j.core.model.iface.OsmEntity) OsmMetadata(de.topobyte.osm4j.core.model.iface.OsmMetadata) OsmMetadata(de.topobyte.osm4j.core.model.iface.OsmMetadata) Metadata(de.topobyte.osm4j.core.model.impl.Metadata)

Aggregations

OsmEntity (de.topobyte.osm4j.core.model.iface.OsmEntity)3 OsmMetadata (de.topobyte.osm4j.core.model.iface.OsmMetadata)2 ByteString (com.google.protobuf.ByteString)1 OsmTag (de.topobyte.osm4j.core.model.iface.OsmTag)1 Metadata (de.topobyte.osm4j.core.model.impl.Metadata)1