void runJavaScriptTranslateTest() { OgrReader uut; Progress progress("runBasicTest"); shared_ptr<OsmMap> map(new OsmMap()); uut.setTranslationFile("translations/cloudmade.js"); uut.read("test-files/jakarta_raya_coastline.shp", "", map, progress); CPPUNIT_ASSERT_EQUAL(604, map->getNodeMap().size()); CPPUNIT_ASSERT_EQUAL(6, (int)map->getWays().size()); int shoreline = 0; int water = 0; for (WayMap::const_iterator it = map->getWays().begin(); it != map->getWays().end(); ++it) { shared_ptr<Way> w = it->second; if (w->getTags()["natural"] == "shoreline") { shoreline++; } if (w->getTags()["natural"] == "water") { water++; } } CPPUNIT_ASSERT_EQUAL(5, shoreline); CPPUNIT_ASSERT_EQUAL(1, water); }
void BaseCommand::loadMap(shared_ptr<OsmMap> map, QString path, bool useFileId, Status defaultStatus) { if (path.endsWith(".geonames")) { GeoNamesReader reader; reader.setDefaultStatus(defaultStatus); reader.read(path, map); } else { QStringList pathLayer = path.split(";"); QString justPath = pathLayer[0]; if (OgrReader::isReasonablePath(justPath)) { OgrReader reader; Progress progress(getName()); reader.setDefaultStatus(defaultStatus); reader.read(justPath, pathLayer.size() > 1 ? pathLayer[1] : "", map, progress); } else { OsmMapReaderFactory::read(map, path, useFileId, defaultStatus); } } }
void runBasicTest() { OgrReader uut; Progress progress("runBasicTest"); shared_ptr<OsmMap> map(new OsmMap()); uut.read("test-files/jakarta_raya_coastline.shp", "", map, progress); CPPUNIT_ASSERT_EQUAL(604, map->getNodeMap().size()); CPPUNIT_ASSERT_EQUAL(6, (int)map->getWays().size()); }
void IoUtils::loadMap(OsmMapPtr map, QString path, bool useFileId, Status defaultStatus) { QStringList pathLayer = path.split(";"); QString justPath = pathLayer[0]; if (OgrReader::isReasonablePath(justPath)) { OgrReader reader; Progress progress("OsmUtils"); reader.setDefaultStatus(defaultStatus); reader.read(justPath, pathLayer.size() > 1 ? pathLayer[1] : "", map, progress); } else { OsmMapReaderFactory::read(map, path, useFileId, defaultStatus); } }
QString AttributeCount::Count(QString input) { QString finalText; int maxAttributes = ConfigOptions().getAttributeCountValues(); OgrReader reader; reader.setTranslationFile(QString(getenv("HOOT_HOME")) + "/translations/quick.js"); QStringList layers; if (input.contains(";")) { QStringList list = input.split(";"); input = list.at(0); layers.append(list.at(1)); } else { layers = reader.getFilteredLayerNames(input); } if (layers.size() == 0) { LOG_WARN("Could not find any valid layers to read from in " + input + "."); } for (int i = 0; i < layers.size(); i++) { AttributeCountHash result; LOG_DEBUG("Reading: " + input + " " + layers[i]); shared_ptr<ElementIterator> iterator(reader.createIterator(input, layers[i])); while(iterator->hasNext()) { shared_ptr<Element> e = iterator->next(); // // Interesting problem: If there are no elements in the file, e == 0 // // Need to look at the ElementIterator.cpp file to fix this. // if (e == 0) // { // LOG_WARN("No features in: " + input + " " + layer); // break; // } Tags t = e->getTags(); for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it) { if (it.value() == "") // Drop empty values { continue; } // Drop Hoot metadata tags if (it.key() == "source:ingest:datetime") { continue; } // The default is 30 values if (result.value(it.key()).size() < maxAttributes ) { result[it.key()][it.value()]++; } } } // End Layer QString tmpText = _printJSON(layers[i], result); // Skip empty layers if (tmpText == "") { continue; } finalText += tmpText; if (i != (layers.size() - 1)) { finalText += ",\n"; } } // End layer list return finalText; } // End AttributeCount