Search in sources :

Example 71 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class PKIStatusInfo method encode.

@Override
public void encode(Tag implicitTag, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(status);
    if (statusString.size() > 0) {
        seq.addElement(statusString);
    }
    if (hasFailInfo) {
        // convert failInfo to BIT_STRING
        byte[] bytes = new byte[2];
        bytes[0] = (byte) ((failInfo & 0xff000000) >>> 24);
        bytes[1] = (byte) ((failInfo & 0x00ff0000) >>> 16);
        // 7 unused bits
        int padCount = 7;
        BIT_STRING bs = new BIT_STRING(bytes, padCount);
        bs.setRemoveTrailingZeroes(true);
        seq.addElement(bs);
    }
    seq.encode(implicitTag, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) BIT_STRING(org.mozilla.jss.asn1.BIT_STRING)

Example 72 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class OsmosisBinaryParser method parseDense.

@Override
protected void parseDense(Osmformat.DenseNodes nodes) {
    long lastId = 0, lastLat = 0, lastLon = 0;
    // Index into the keysvals array.
    int j = 0;
    // Stuff for dense info
    long lasttimestamp = 0, lastchangeset = 0;
    int lastuserSid = 0, lastuid = 0;
    Osmformat.DenseInfo di = null;
    if (nodes.hasDenseinfo()) {
        di = nodes.getDenseinfo();
    }
    for (int i = 0; i < nodes.getIdCount(); i++) {
        Node tmp;
        List<Tag> tags = new ArrayList<Tag>(0);
        long lat = nodes.getLat(i) + lastLat;
        lastLat = lat;
        long lon = nodes.getLon(i) + lastLon;
        lastLon = lon;
        long id = nodes.getId(i) + lastId;
        lastId = id;
        double latf = parseLat(lat), lonf = parseLon(lon);
        // If empty, assume that nothing here has keys or vals.
        if (nodes.getKeysValsCount() > 0) {
            while (nodes.getKeysVals(j) != 0) {
                int keyid = nodes.getKeysVals(j++);
                int valid = nodes.getKeysVals(j++);
                tags.add(new Tag(getStringById(keyid), getStringById(valid)));
            }
            // Skip over the '0' delimiter.
            j++;
        }
        // Handle dense info.
        if (di != null) {
            int uid = di.getUid(i) + lastuid;
            lastuid = uid;
            int userSid = di.getUserSid(i) + lastuserSid;
            lastuserSid = userSid;
            long timestamp = di.getTimestamp(i) + lasttimestamp;
            lasttimestamp = timestamp;
            int version = di.getVersion(i);
            long changeset = di.getChangeset(i) + lastchangeset;
            lastchangeset = changeset;
            Date date = new Date(date_granularity * timestamp);
            OsmUser user;
            if (uid < 0) {
                user = OsmUser.NONE;
            } else {
                user = new OsmUser(uid, getStringById(userSid));
            }
            tmp = new Node(new CommonEntityData(id, version, date, user, changeset, tags), latf, lonf);
        } else {
            tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), latf, lonf);
        }
        sink.process(new NodeContainer(tmp));
    }
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) ArrayList(java.util.ArrayList) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Osmformat(crosby.binary.Osmformat) Date(java.util.Date) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 73 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class OsmosisBinaryParser method parseWays.

@Override
protected void parseWays(List<Osmformat.Way> ways) {
    for (Osmformat.Way i : ways) {
        List<Tag> tags = new ArrayList<Tag>();
        for (int j = 0; j < i.getKeysCount(); j++) {
            tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
        }
        long lastId = 0;
        long lastLat = 0;
        long lastLon = 0;
        List<WayNode> nodes = new ArrayList<WayNode>();
        for (int index = 0; index < i.getRefsCount(); index++) {
            long identifier = lastId + i.getRefs(index);
            WayNode node;
            if (index < i.getLatCount() && index < i.getLonCount()) {
                long lat = lastLat + i.getLat(index);
                long lon = lastLon + i.getLon(index);
                node = new WayNode(identifier, parseLat(lat), parseLon(lon));
                lastLat = lat;
                lastLon = lon;
            } else {
                node = new WayNode(identifier);
            }
            nodes.add(node);
            lastId = identifier;
        }
        long id = i.getId();
        // long id, int version, Date timestamp, OsmUser user,
        // long changesetId, Collection<Tag> tags,
        // List<WayNode> wayNodes
        Way tmp;
        if (i.hasInfo()) {
            Osmformat.Info info = i.getInfo();
            tmp = new Way(new CommonEntityData(id, info.getVersion(), getDate(info), getUser(info), info.getChangeset(), tags), nodes);
        } else {
            tmp = new Way(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), nodes);
        }
        sink.process(new WayContainer(tmp));
    }
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) WayContainer(org.openstreetmap.osmosis.core.container.v0_6.WayContainer) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) ArrayList(java.util.ArrayList) Osmformat(crosby.binary.Osmformat) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 74 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class OsmosisBinaryParser method parseNodes.

@Override
protected void parseNodes(List<Osmformat.Node> nodes) {
    for (Osmformat.Node i : nodes) {
        List<Tag> tags = new ArrayList<Tag>();
        for (int j = 0; j < i.getKeysCount(); j++) {
            tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
        }
        // long id, int version, Date timestamp, OsmUser user,
        // long changesetId, Collection<Tag> tags,
        // double latitude, double longitude
        Node tmp;
        long id = i.getId();
        double latf = parseLat(i.getLat()), lonf = parseLon(i.getLon());
        if (i.hasInfo()) {
            Osmformat.Info info = i.getInfo();
            tmp = new Node(new CommonEntityData(id, info.getVersion(), getDate(info), getUser(info), info.getChangeset(), tags), latf, lonf);
        } else {
            tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, NOCHANGESET, tags), latf, lonf);
        }
        sink.process(new NodeContainer(tmp));
    }
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) ArrayList(java.util.ArrayList) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Osmformat(crosby.binary.Osmformat)

Example 75 with Tag

use of org.mozilla.jss.asn1.Tag in project osmosis by openstreetmap.

the class CopyFilesetBuilder method process.

/**
 * {@inheritDoc}
 */
public void process(NodeContainer nodeContainer) {
    Node node;
    node = nodeContainer.getEntity();
    nodeWriter.writeField(node.getId());
    nodeWriter.writeField(node.getVersion());
    nodeWriter.writeField(node.getUser().getId());
    nodeWriter.writeField(node.getTimestamp());
    nodeWriter.writeField(node.getChangesetId());
    nodeWriter.writeField(pointBuilder.createPoint(node.getLatitude(), node.getLongitude()));
    nodeWriter.endRecord();
    for (Tag tag : node.getTags()) {
        nodeTagWriter.writeField(node.getId());
        nodeTagWriter.writeField(tag.getKey());
        nodeTagWriter.writeField(tag.getValue());
        nodeTagWriter.endRecord();
    }
    if (enableBboxBuilder || enableLinestringBuilder) {
        wayGeometryBuilder.addNodeLocation(node);
    }
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)23 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Date (java.util.Date)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Tag (org.mozilla.jss.asn1.Tag)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)6 Osmformat (crosby.binary.Osmformat)5 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)5 Point (com.vividsolutions.jts.geom.Point)4