[Git][debian-gis-team/osmpbf][master] 2 commits: Add autopkgtests to catch PBF read failures.

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Sun Nov 6 12:51:01 GMT 2022



Bas Couwenberg pushed to branch master at Debian GIS Project / osmpbf


Commits:
c9b7d286 by Bas Couwenberg at 2022-11-06T13:49:00+01:00
Add autopkgtests to catch PBF read failures.

- - - - -
46d6040e by Bas Couwenberg at 2022-11-06T13:49:19+01:00
Enable Salsa CI.

- - - - -


6 changed files:

- + debian/.gitlab-ci.yml
- debian/changelog
- + debian/tests/ReadPBF.java
- + debian/tests/control
- + debian/tests/java
- + debian/tests/osmpbf-outline


Changes:

=====================================
debian/.gitlab-ci.yml
=====================================
@@ -0,0 +1,3 @@
+include:
+  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
+  - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml


=====================================
debian/changelog
=====================================
@@ -1,6 +1,8 @@
 osmpbf (1.5.0-3) UNRELEASED; urgency=medium
 
   * Bump Standards-Version to 4.6.1, no changes.
+  * Add autopkgtests to catch PBF read failures.
+  * Enable Salsa CI.
 
  -- Bas Couwenberg <sebastic at debian.org>  Tue, 21 Jun 2022 07:15:36 +0200
 


=====================================
debian/tests/ReadPBF.java
=====================================
@@ -0,0 +1,173 @@
+import java.lang.Exception;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import crosby.binary.BinaryParser;
+import crosby.binary.Osmformat;
+import crosby.binary.file.BlockInputStream;
+
+class ReadPBF {
+
+    public static void main(String args[]) {
+        String filename = args[0];
+
+        System.out.println("Reading: " + filename);
+
+        File input = new File(filename);
+
+        try {
+            InputStream is = new FileInputStream(input);
+
+            parse(is);
+        } catch (FileNotFoundException e) {
+            System.out.println("Error: File not found!");
+            System.exit(1);
+        }
+    }
+
+    public static void parse(InputStream is) {
+        try {
+            BinParser reader = new BinParser();
+            BlockInputStream stream = new BlockInputStream(is, reader);
+            stream.process();
+        } catch (IOException e) {
+            System.out.println("Error: Failed to parse PBF");
+            System.exit(1);
+        }
+    }
+
+    public static class BinParser extends BinaryParser {
+
+        protected void parse(Osmformat.HeaderBlock header) {
+            System.out.println("Parsing HeaderBlock");
+
+            if (header.hasBbox()) {
+                double multiplier = .000000001;
+                double maxLon = header.getBbox().getRight() * multiplier;
+                double minLon = header.getBbox().getLeft() * multiplier;
+                double maxLat = header.getBbox().getTop() * multiplier;
+                double minLat = header.getBbox().getBottom() * multiplier;
+
+                System.out.println(" BBOX: " + minLat + "," + minLon + "," + maxLat + "," + maxLon);
+            }
+            for (String s : header.getRequiredFeaturesList()) {
+                System.out.println(" Feature: " + s);
+            }
+
+        }
+        protected void parseNodes(List<Osmformat.Node> nodes) {
+            System.out.println("Parsing nodes");
+
+            for (Osmformat.Node n : nodes) {
+                System.out.println(" node:" + n.getId());
+                System.out.println("  Lat/Lon: " + n.getLat() + "," + n.getLon());
+
+                System.out.println("  Tags: " + n.getKeysCount());
+                for (int j = 0; j < n.getKeysCount(); j++) {
+                    String key = getStringById(n.getKeys(j));
+                    String val = getStringById(n.getVals(j));
+
+                    System.out.println("   " + key + "=" + val);
+                }
+            }
+        }
+
+        protected final void parseDense(Osmformat.DenseNodes nodes) {
+            System.out.println("Parsing dense nodes");
+
+            long lastId = 0, lastLat = 0, lastLon = 0;
+
+            int kvid = 0;
+
+            for (int i = 0; i < nodes.getIdCount(); i++) {
+                long lat = nodes.getLat(i) + lastLat;
+                long lon = nodes.getLon(i) + lastLon;
+                long id = nodes.getId(i) + lastId;
+                lastLat = lat;
+                lastLon = lon;
+                lastId = id;
+
+                System.out.println(" node:" + id);
+                System.out.println("  Lat/Lon: " + lat + "," + lon);
+
+                if (nodes.getKeysValsCount() > 0) {
+                    while (nodes.getKeysVals(kvid) != 0) {
+                        int keyid = nodes.getKeysVals(kvid++);
+                        int valid = nodes.getKeysVals(kvid++);
+                        String key = getStringById(keyid);
+                        String val = getStringById(valid);
+
+                        System.out.println("   " + key + "=" + val);
+                    }
+                    kvid++; // Skip over the '0' delimiter.
+                }
+            }
+        }
+
+        protected void parseWays(List<Osmformat.Way> ways) {
+            System.out.println("Parsing ways");
+
+            for (Osmformat.Way w : ways) {
+                System.out.println(" way:" + w.getId());
+
+                System.out.println("  Tags: " + w.getKeysCount());
+                for (int j = 0; j < w.getKeysCount(); j++) {
+                    String key = getStringById(w.getKeys(j));
+                    String val = getStringById(w.getVals(j));
+
+                    System.out.println("   " + key + "=" + val);
+                }
+
+                System.out.println("");
+                System.out.println("  Nodes: " + w.getRefsCount());
+
+                long nid = 0;
+                for (long idDelta : w.getRefsList()) {
+                    nid += idDelta;
+                    System.out.println("   nd:" + nid);
+                }
+            }
+        }
+
+        protected void parseRelations(List<Osmformat.Relation> rels) {
+            System.out.println("Parsing relations");
+
+            for (Osmformat.Relation r : rels) {
+                System.out.println(" relation:" + r.getId());
+
+                System.out.println("  Tags: " + r.getKeysCount());
+                for (int j = 0; j < r.getKeysCount(); j++) {
+                    String key = getStringById(r.getKeys(j));
+                    String val = getStringById(r.getVals(j));
+
+                    System.out.println("   " + key + "=" + val);
+                }
+
+                System.out.println("");
+                System.out.println("  Members: " + r.getMemidsCount());
+
+                long lastMid = 0;
+
+                for (int j = 0; j < r.getMemidsCount(); j++) {
+                    long mid = lastMid + r.getMemids(j);
+                    lastMid = mid;
+                    String role = getStringById(r.getRolesSid(j));
+
+                    System.out.println("   role:" + role);
+                    System.out.println("   type:" + r.getTypes(j));
+                    System.out.println("    ref:" + mid);
+                    System.out.println("");
+                }
+            }
+        }
+
+	public void complete() {
+            System.out.println("Parsing complete");
+	}
+    }
+}
+


=====================================
debian/tests/control
=====================================
@@ -0,0 +1,13 @@
+Tests: java
+Depends: ca-certificates,
+         default-jdk-headless,
+         libosmpbf-java,
+         libprotobuf-java,
+         wget
+Restrictions: needs-internet
+
+Tests: osmpbf-outline
+Depends: ca-certificates,
+         osmpbf-bin,
+         wget
+Restrictions: needs-internet


=====================================
debian/tests/java
=====================================
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+TESTS_DIR="$(realpath "$(dirname "$0")")"
+DEBIAN_DIR="$(dirname "${TESTS_DIR}")"
+PACKAGE_DIR="$(dirname "${DEBIAN_DIR}")"
+
+CLASSPATH="."
+CLASSPATH="${CLASSPATH}:/usr/share/java/osmpbf.jar"
+CLASSPATH="${CLASSPATH}:/usr/share/java/protobuf.jar"
+
+DATASET_URL="https://download.geofabrik.de/europe/andorra-latest.osm.pbf"
+DATASET_FILE="andorra-latest.osm.pbf"
+
+TEMPDIR="$(mktemp -d)"
+
+cd "${TEMPDIR}" || exit 1
+
+wget -q "${DATASET_URL}" -O "${DATASET_FILE}"
+RC=$?
+
+if [ "${RC}" -ne 0 ]; then
+    cd "${OLDPWD}" || exit 1
+    rm -rf "${TEMPDIR}"
+
+    exit "${RC}"
+fi
+
+cp -rv ${TESTS_DIR}/*.java .
+RC=$?
+
+if [ "${RC}" -ne 0 ]; then
+    cd "${OLDPWD}" || exit 1
+    rm -rf "${TEMPDIR}"
+
+    exit "${RC}"
+fi
+
+javac -cp "${CLASSPATH}" ReadPBF.java
+RC=$?
+
+if [ "${RC}" -ne 0 ]; then
+    cd "${OLDPWD}" || exit 1
+    rm -rf "${TEMPDIR}"
+
+    exit "${RC}"
+fi
+
+java -cp "${CLASSPATH}" ReadPBF "${DATASET_FILE}"
+RC=$?
+
+cd "${OLDPWD}" || exit 1
+rm -rf "${TEMPDIR}"
+
+exit "${RC}"


=====================================
debian/tests/osmpbf-outline
=====================================
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+DATASET_URL="https://download.geofabrik.de/europe/monaco-latest.osm.pbf"
+DATASET_FILE="monaco-latest.osm.pbf"
+
+TEMPDIR="$(mktemp -d)"
+
+cd "${TEMPDIR}" || exit 1
+
+wget -q "${DATASET_URL}" -O "${DATASET_FILE}"
+RC=$?
+
+if [ "${RC}" -ne 0 ]; then
+    cd "${OLDPWD}" || exit 1
+    rm -rf "${TEMPDIR}"
+
+    exit "${RC}"
+fi
+
+osmpbf-outline --color "${DATASET_FILE}"
+RC=$?
+
+cd "${OLDPWD}" || exit 1
+rm -rf "${TEMPDIR}"
+
+exit "${RC}"



View it on GitLab: https://salsa.debian.org/debian-gis-team/osmpbf/-/compare/9d76d9188a52ba5680b8a891d32114d228e14e55...46d6040e00bfd27e5162f0780963f09d9f786eb8

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/osmpbf/-/compare/9d76d9188a52ba5680b8a891d32114d228e14e55...46d6040e00bfd27e5162f0780963f09d9f786eb8
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20221106/f6264dcb/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list