Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ RSpec::Core::RakeTask.new(:spec) do |task|
end

task :default => :spec

Dir['tasks/*.rake'].each { |f| load f }
26 changes: 26 additions & 0 deletions spec/fixtures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Fixtures

Every file in this directory is generated by `tasks/fixtures.rake`:

```sh
bundle exec rake fixtures:build
```

If you need a new case, add it to the task and regenerate, so that the next person can see what
a fixture contains without unzipping it.

The only external tool involved is `ogr2ogr`, which writes the shapefile components and is
already needed to run the suite. The JPEGs embedded in `kmz_with_images.kmz` come from a
constant in the task.

The geometry is deliberately dull: squares on a regular grid, in NAD83 / UTM zone 11N for the
shapefiles and in round degrees for the KML. What matters in each fixture is its structure
rather than its coordinates — a missing `.shx`, a `.shx` whose basename does not match the
`.shp`, a `__MACOSX` decoy carrying a real extension, a single-vertex LineString, a null
geometry, a name longer than the name column. The specs assert on feature counts and on those
structures, so regenerating with different coordinates is safe, while changing a count, a
component filename, or a placemark name is not.

Regenerating rewrites the archives in place, and their entry timestamps change every run, so
expect git to report them modified even when nothing about their contents has. Run the suite
afterwards; it is the check that the structures survived.
Binary file modified spec/fixtures/archive_containing_kmz.zip
Binary file not shown.
Binary file modified spec/fixtures/archive_with_multiple_kmls.zip
Binary file not shown.
Binary file modified spec/fixtures/archive_with_multiple_shps.zip
Binary file not shown.
Binary file modified spec/fixtures/archive_without_any_known_file.zip
Binary file not shown.
154 changes: 75 additions & 79 deletions spec/fixtures/geo.json
Original file line number Diff line number Diff line change
@@ -1,85 +1,81 @@
{
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"properties":{
"name":"Feature A",
"prop0": "value"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-121.30360205078127,
51.240061941441795
],
[
-120.67188818359377,
50.95373510735458
],
[
-121.19373876953127,
50.88447544421283
],
[
-121.30360205078127,
51.240061941441795
]
]
]
}
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "Feature A",
"prop0": "value"
},
{
"type":"Feature",
"properties":{
"name":"Feature B",
"prop0": "value"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-122.41871435546877,
51.34654878111497
],
[
-121.77052099609377,
51.53828646289825
],
[
-121.75953466796877,
51.38084670223434
],
[
-121.94630224609377,
51.195332650242506
],
[
-122.14405615234377,
51.10574365681173
],
[
-122.34730322265627,
51.11608972528383
],
[
-122.41871435546877,
51.34654878111497
]
]
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
10,
20
],
[
11,
20
],
[
11,
21
],
[
10,
21
],
[
10,
20
]
}
]
]
}
},
{
"type": "Feature",
"properties": {
"name": "Feature B",
"prop0": "value"
},
{
"type":"Feature",
"properties":{
"name":"Feature C",
"prop0": "value"
},
"geometry": null
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
30,
40
],
[
31,
40
],
[
31,
41
],
[
30,
41
],
[
30,
40
]
]
]
}
]
},
{
"type": "Feature",
"properties": {
"name": "Feature C",
"prop0": "value"
},
"geometry": null
}
]
}
117 changes: 17 additions & 100 deletions spec/fixtures/kml_file_with_altitude.kml
Original file line number Diff line number Diff line change
@@ -1,102 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>test.kml</name>
<Style id="s_ylw-pushpin">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<StyleMap id="msn_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>#sn_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#sh_ylw-pushpin</styleUrl>
</Pair>
</StyleMap>
<Style id="sh_ylw-pushpin">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
<PolyStyle>
<color>ffff9572</color>
</PolyStyle>
</Style>
<StyleMap id="m_ylw-pushpin">
<Pair>
<key>normal</key>
<styleUrl>#s_ylw-pushpin</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#s_ylw-pushpin_hl</styleUrl>
</Pair>
</StyleMap>
<Style id="s_ylw-pushpin_hl">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>
<Style id="sn_ylw-pushpin">
<IconStyle>
<scale>1.1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
<PolyStyle>
<color>ffff9572</color>
</PolyStyle>
</Style>
<Folder>
<name>Poly folder</name>
<open>1</open>
<Placemark>
<name>Poly 1</name>
<description>This polygon has 3D geometry</description>
<styleUrl>#m_ylw-pushpin</styleUrl>
<gx:balloonVisibility>1</gx:balloonVisibility>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-116.7515403029528,49.08210926772687,-5.976855754852295e-05 -116.7512693508186,49.08231630032653,-5.976855754852295e-05 -116.7510313015289,49.08248832080875,-5.976948887109756e-05 -116.7508471244029,49.08248531472098,-5.977042019367218e-05 -116.7503725125688,49.08250416936566,-5.976855754852295e-05 -116.7496625281544,49.08273345629574,-5.976855754852295e-05 -116.7489779002949,49.08298438319456,-5.977042019367218e-05 -116.7488946064397,49.08301748537436,-5.97713515162468e-05 -116.7490631198219,49.08327575277079,-5.977228283882141e-05 -116.749318497487,49.08358107512755,-5.97713515162468e-05 -116.749436515071,49.08383248565602,-5.977042019367218e-05 -116.7495781555165,49.08407072392254,-5.977042019367218e-05 -116.7498202420291,49.08413349769931,-5.977042019367218e-05 -116.7499457606038,49.08431008140729,-5.977414548397064e-05 -116.7499520489836,49.08431234390348,-5.977228283882141e-05 -116.7503115582278,49.08439165279593,-5.977321416139602e-05 -116.7506718895158,49.08425228182594,-5.977321416139602e-05 -116.7507080125254,49.08423131038275,-5.977414548397064e-05 -116.7507055933694,49.08422212975165,-5.977228283882141e-05 -116.750703739572,49.08420944209784,-5.977414548397064e-05 -116.750703393566,49.08419648783546,-5.977228283882141e-05 -116.7507042819026,49.08418317641901,-5.977228283882141e-05 -116.7507068154278,49.08416950873566,-5.97713515162468e-05 -116.7507105823926,49.0841556638061,-5.977321416139602e-05 -116.7507157192947,49.08414173187993,-5.977321416139602e-05 -116.7507223635321,49.08412762329866,-5.977228283882141e-05 -116.7507301038066,49.08411342712892,-5.977321416139602e-05 -116.7507392135647,49.08409923391582,-5.977321416139602e-05 -116.7507496923549,49.08408513361309,-5.977321416139602e-05 -116.750761266729,49.084071035675,-5.97713515162468e-05 -116.7507739353355,49.08405720996314,-5.977228283882141e-05 -116.7507879725211,49.08404356711452,-5.977228283882141e-05 -116.7508028295902,49.08403028585404,-5.977321416139602e-05 -116.7508187813398,49.08401718686463,-5.977414548397064e-05 -116.7508356894705,49.08400453971223,-5.977228283882141e-05 -116.7508534170337,49.08399234410085,-5.977321416139602e-05 -116.7508721014275,49.08398051037167,-5.977321416139602e-05 -116.7508913300066,49.0839693974536,-5.977228283882141e-05 -116.750911378468,49.08395864612137,-5.977321416139602e-05 -116.7509319715652,49.08394852564564,-5.977321416139602e-05 -116.7509529714506,49.08393921563855,-5.977228283882141e-05 -116.7509745164227,49.08393044653347,-5.977228283882141e-05 -116.7509963316859,49.08392239764715,-5.977321416139602e-05 -116.7510182793931,49.08391524859208,-5.97713515162468e-05 -116.7510404978429,49.08390872980158,-5.977042019367218e-05 -116.7510627117906,49.08390311054676,-5.977228283882141e-05 -116.7510850590848,49.08389821121501,-5.97713515162468e-05 -116.7511072653803,49.08389412116959,-5.977228283882141e-05 -116.7511291928312,49.08389102002342,-5.977228283882141e-05 -116.7511508418881,49.08388881782259,-5.977414548397064e-05 -116.7511720760536,49.08388742431816,-5.97713515162468e-05 -116.7511930318276,49.08388692975941,-5.97713515162468e-05 -116.751213297917,49.08388742321508,-5.97713515162468e-05 -116.7512330126194,49.0838886351187,-5.977228283882141e-05 -116.7512520376394,49.08389083503734,-5.977228283882141e-05 -116.7512702369284,49.08389384276833,-5.97713515162468e-05 -116.7512843268737,49.08389702155225,-5.977042019367218e-05 -116.7512876095886,49.08389783822006,-5.97713515162468e-05 -116.7513041569684,49.08390255153084,-5.97713515162468e-05 -116.7513197412218,49.08390816231408,-5.977228283882141e-05 -116.7513342258501,49.0839145803211,-5.977228283882141e-05 -116.7513476108535,49.08392180555226,-5.97713515162468e-05 -116.7513597597331,49.08392974775903,-5.977228283882141e-05 -116.751370809437,49.08393840723678,-5.977414548397064e-05 -116.7513807599652,49.08394778398574,-5.977228283882141e-05 -116.7513893383187,49.08395769750831,-5.977228283882141e-05 -116.75139654315,49.08396841766687,-5.977228283882141e-05 -116.7514023767035,49.08397949469153,-5.977228283882141e-05 -116.7514071110794,49.08399128898851,-5.977321416139602e-05 -116.7514077854947,49.08399335940517,-5.977321416139602e-05 -116.7514102002792,49.08400343956209,-5.977414548397064e-05 -116.7514119173006,49.08401612691037,-5.97713515162468e-05 -116.7514122639388,49.08402899121732,-5.977228283882141e-05 -116.7514113753453,49.08404239259393,-5.977228283882141e-05 -116.7514089789687,49.08405606058831,-5.977228283882141e-05 -116.7514052126546,49.08406981558722,-5.977321416139602e-05 -116.7514000750547,49.0840839274526,-5.977228283882141e-05 -116.751393431464,49.08409794611927,-5.977414548397064e-05 -116.7513856909318,49.08411223228784,-5.977321416139602e-05 -116.7513764448556,49.08412633530327,-5.977321416139602e-05 -116.7513659662339,49.08414043566304,-5.97713515162468e-05 -116.7513543920146,49.08415453366188,-5.977321416139602e-05 -116.7513417235442,49.08416835943742,-5.977414548397064e-05 -116.7513278234237,49.08418200264829,-5.97713515162468e-05 -116.7513128294999,49.08419528368113,-5.977228283882141e-05 -116.7512970147718,49.08420838303356,-5.977228283882141e-05 -116.7512801066886,49.08422103025315,-5.977321416139602e-05 -116.7512622417496,49.08423331558855,-5.977228283882141e-05 -116.7512436947518,49.08424505972144,-5.977228283882141e-05 -116.7512243287458,49.08425626235651,-5.977228283882141e-05 -116.7512042806811,49.08426692378845,-5.977321416139602e-05 -116.7511836875072,49.08427704431207,-5.977321416139602e-05 -116.7511626870726,49.0842864443144,-5.977228283882141e-05 -116.7511411424287,49.08429512349989,-5.977228283882141e-05 -116.7511193274749,49.08430308245879,-5.97713515162468e-05 -116.7510973791614,49.08431032148636,-5.977228283882141e-05 -116.7510751605396,49.0843168402871,-5.977228283882141e-05 -116.7510529464086,49.0843224595436,-5.977228283882141e-05 -116.7510307363199,49.08432726920987,-5.977228283882141e-05 -116.7510085298248,49.08433135923989,-5.977321416139602e-05 -116.750986739122,49.08433446065798,-5.977414548397064e-05 -116.7509648155154,49.08433675219059,-5.977228283882141e-05 -116.7509437185519,49.08433805599805,-5.977414548397064e-05 -116.7509227625858,49.08433855051116,-5.977228283882141e-05 -116.7509024954161,49.08433823691217,-5.977507680654526e-05 -116.7508826440445,49.08433693470243,-5.977321416139602e-05 -116.7508637558201,49.0843347350184,-5.977321416139602e-05 -116.7508454194455,49.0843317269277,-5.977507680654526e-05 -116.7508305095092,49.08432818650067,-5.977228283882141e-05 -116.7507919141879,49.08435059192375,-5.977321416139602e-05 -116.7507901284429,49.08435166752803,-5.977414548397064e-05 -116.7507770880808,49.08435766635651,-5.977507680654526e-05 -116.7505519150925,49.08444479611104,-5.977321416139602e-05 -116.7510549293909,49.08455589694681,-5.977321416139602e-05 -116.7515202853279,49.08439228203611,-5.977414548397064e-05 -116.7524138826689,49.08398076912792,-5.977321416139602e-05 -116.7524158057612,49.08397960383811,-5.977228283882141e-05 -116.7524167720029,49.0839780766761,-5.977228283882141e-05 -116.7524171908977,49.08397645838516,-5.97713515162468e-05 -116.7523125841168,49.08369647401459,-5.977228283882141e-05 -116.7521292884352,49.08326780492037,-5.97713515162468e-05 -116.7520054599166,49.08310831863499,-5.97713515162468e-05 -116.7518159515976,49.0827181363844,-5.977042019367218e-05 -116.7517886110814,49.08254347496219,-5.977042019367218e-05 -116.7516055433862,49.08215321621999,-5.97713515162468e-05 -116.7515925599111,49.08206557211205,-5.976855754852295e-05 -116.7515403029528,49.08210926772687,-5.976855754852295e-05
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Poly 2</name>
<description>This is a description also</description>
<styleUrl>#msn_ylw-pushpin</styleUrl>
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-106.4303166516638,61.16376575099101,0 -100.7627103394292,61.95514185121152,0 -100.2655658472707,65.8275552135498,0 -107.9516815833805,65.21804505333482,0 -106.4303166516638,61.16376575099101,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Folder>
</Document>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>test.kml</name>
<Folder>
<name>Poly folder</name>
<Placemark>
<name>Poly 1</name>
<description>This is a description</description>
<Polygon><outerBoundaryIs><LinearRing><coordinates>10,20,-5.976855754852295e-05 11,20,-5.976855754852295e-05 11,21,-5.976855754852295e-05 10,21,-5.976855754852295e-05 10,20,-5.976855754852295e-05</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
<Placemark>
<name>Poly 2</name>
<description>This is a description also</description>
<Polygon><outerBoundaryIs><LinearRing><coordinates>30,40 31,40 31,41 30,41 30,40</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
</Folder>
</Document>
</kml>
31 changes: 12 additions & 19 deletions spec/fixtures/kml_file_with_ground_overlay.kml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>kml_file_with_ground_overlay.kml</name>
<Folder>
<name>Overlay folder</name>
<GroundOverlay>
<name>Provincial Boundary</name>
<Icon>
<href>https://example.com/wms?service=wms&amp;request=GetMap</href>
</Icon>
<LatLonBox>
<north>55.4</north>
<south>52.9</south>
<east>-117.4</east>
<west>-122.5</west>
</LatLonBox>
</GroundOverlay>
</Folder>
</Document>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>kml_file_with_ground_overlay.kml</name>
<Folder>
<name>Overlay folder</name>
<GroundOverlay>
<name>Basemap Overlay</name>
<Icon><href>https://example.com/wms?service=wms&amp;request=GetMap</href></Icon>
<LatLonBox><north>41</north><south>39</south><east>31</east><west>29</west></LatLonBox>
</GroundOverlay>
</Folder>
</Document>
</kml>
Loading