gen_kml_testdata.sh (3198B)
1 #!/bin/sh 2 # This file is part of libextractor. 3 # Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 # 5 # Regenerate src/plugins/testdata/kml_test.kml. 6 # 7 # Requires: nothing beyond a POSIX shell -- the file is plain text and is 8 # written out literally, so the result is byte-for-byte reproducible. 9 # 10 # The file is an OGC KML 2.2 document that exercises what the kml plugin 11 # parses: the document name and an HTML-bearing CDATA description, an 12 # atom:author and atom:link, a <LookAt> (the *viewer's* position, which 13 # the plugin must not confuse with the data), a <TimeStamp>, three 14 # Placemarks -- two points and one LineString -- and a <NetworkLink>, 15 # which is the forensically interesting bit because it means opening the 16 # file fetches something from a remote host. 17 # 18 # The data is invented (the same Zurich walk as gpx_test.gpx, so that the 19 # two plugins can be compared) and is dedicated to the public domain 20 # (CC0). Note that KML coordinates are lon,lat[,alt] -- the reverse of 21 # the GPX attribute order. 22 set -e 23 24 srcdir=$(dirname "$0")/.. 25 out="$srcdir/src/plugins/testdata/kml_test.kml" 26 27 cat > "$out" <<'EOF' 28 <?xml version="1.0" encoding="UTF-8"?> 29 <kml xmlns="http://www.opengis.net/kml/2.2" 30 xmlns:atom="http://www.w3.org/2005/Atom" 31 xmlns:gx="http://www.google.com/kml/ext/2.2"> 32 <Document> 33 <name>Zurich morning walk</name> 34 <description><![CDATA[<p>Exported from the handheld on 35 <b>2024-03-15</b>. See <a href="https://example.com/~anna/">the 36 index</a> for the other days.</p>]]></description> 37 <atom:author> 38 <atom:name>Anna Mueller</atom:name> 39 </atom:author> 40 <atom:link href="https://example.com/~anna/"/> 41 <TimeStamp> 42 <when>2024-03-15T07:12:00Z</when> 43 </TimeStamp> 44 <LookAt> 45 <longitude>8.547000</longitude> 46 <latitude>47.381000</latitude> 47 <altitude>0</altitude> 48 <range>1200</range> 49 <tilt>45</tilt> 50 <heading>10</heading> 51 </LookAt> 52 <Style id="track"> 53 <LineStyle> 54 <color>ff0000ff</color> 55 <width>4</width> 56 </LineStyle> 57 </Style> 58 <Placemark> 59 <name>Home</name> 60 <description>Start of the recording</description> 61 <Point> 62 <coordinates>8.541694,47.376890,408.2</coordinates> 63 </Point> 64 </Placemark> 65 <Placemark> 66 <name>Office</name> 67 <description>End of the recording</description> 68 <Point> 69 <coordinates>8.552300,47.385100,419.3</coordinates> 70 </Point> 71 </Placemark> 72 <Placemark> 73 <name>Walked track</name> 74 <styleUrl>#track</styleUrl> 75 <LineString> 76 <tessellate>1</tessellate> 77 <coordinates> 78 8.541694,47.376890,408.2 79 8.543210,47.378120,412.5 80 8.546800,47.380450,425.0 81 8.549900,47.382990,430.7 82 8.552300,47.385100,419.3 83 </coordinates> 84 </LineString> 85 </Placemark> 86 <NetworkLink> 87 <name>Live position</name> 88 <Link> 89 <href>https://tracker.example.net/live/anna.kml</href> 90 <refreshMode>onInterval</refreshMode> 91 <refreshInterval>30</refreshInterval> 92 </Link> 93 </NetworkLink> 94 </Document> 95 </kml> 96 EOF 97 98 echo "wrote $out ($(wc -c < "$out") bytes)"