diff --git a/hoot-core/src/main/cpp/hoot/core/io/OsmGeoJsonReader.cpp b/hoot-core/src/main/cpp/hoot/core/io/OsmGeoJsonReader.cpp
index dfaf00a..2f07398 100644
--- a/hoot-core/src/main/cpp/hoot/core/io/OsmGeoJsonReader.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/io/OsmGeoJsonReader.cpp
@@ -80,8 +80,8 @@ bool OsmGeoJsonReader::isSupported(const QString& url)
// Is it a file?
if (isRelativeUrl || isLocalFile)
{
- const QString filename = isRelativeUrl ? myUrl.toString() : myUrl.toLocalFile();
- if (QFile::exists(filename) && url.endsWith(".geojson", Qt::CaseInsensitive))
+ if (url.endsWith(".geojson", Qt::CaseInsensitive) &&
+ !url.startsWith("http", Qt::CaseInsensitive))
{
return true;
}
@@ -278,10 +278,26 @@ void OsmGeoJsonReader::_parseGeoJsonNode(const string& id, const pt::ptree& prop
double lat = coords[0].y;
double lon = coords[0].x;
+
+ long version = ElementData::VERSION_EMPTY;
+ version = properties.get("@version", version);
+ long changeset = ElementData::CHANGESET_EMPTY;
+ changeset = properties.get("@changeset", changeset);
+ unsigned int timestamp = ElementData::TIMESTAMP_EMPTY;
+ timestamp = properties.get("@timestamp", timestamp);
+ std::string user = ElementData::USER_EMPTY.toStdString();
+ user = properties.get("@user", user);
+ long uid = ElementData::UID_EMPTY;
+ uid = properties.get("@uid", uid);
+
// Construct node
- NodePtr pNode(new Node(_defaultStatus, node_id, lon, lat, _defaultCircErr));
+ NodePtr pNode(
+ new Node(
+ _defaultStatus, node_id, lon, lat, _defaultCircErr, changeset, version, timestamp,
+ QString::fromStdString(user), uid));
// Add tags
_addTags(properties, pNode);
+ LOG_VART(pNode);
// Add node to map
_map->addNode(pNode);
@@ -320,8 +336,23 @@ void OsmGeoJsonReader::_parseGeoJsonWay(const string& id, const pt::ptree& prope
}
else
way_id = _map->createNextWayId();
+
+ long version = ElementData::VERSION_EMPTY;
+ version = properties.get("@version", version);
+ long changeset = ElementData::CHANGESET_EMPTY;
+ changeset = properties.get("@changeset", changeset);
+ unsigned int timestamp = ElementData::TIMESTAMP_EMPTY;
+ timestamp = properties.get("@timestamp", timestamp);
+ std::string user = ElementData::USER_EMPTY.toStdString();
+ user = properties.get("@user", user);
+ long uid = ElementData::UID_EMPTY;
+ uid = properties.get("@uid", uid);
+
// Construct Way
- WayPtr way(new Way(_defaultStatus, way_id, _defaultCircErr));
+ WayPtr way(
+ new Way(
+ _defaultStatus, way_id, _defaultCircErr, changeset, version, timestamp,
+ QString::fromStdString(user), uid));
bool isPoly = (geometry.get("type", "").compare("Polygon") == 0);
// Add nodes
@@ -342,6 +373,7 @@ void OsmGeoJsonReader::_parseGeoJsonWay(const string& id, const pt::ptree& prope
}
// Add tags
_addTags(properties, way);
+ LOG_VART(way);
// Add way to map
_map->addWay(way);
@@ -371,10 +403,25 @@ void OsmGeoJsonReader::_parseGeoJsonRelation(const string& id, const pt::ptree&
}
else
relation_id = _map->createNextRelationId();
+
+ long version = ElementData::VERSION_EMPTY;
+ version = properties.get("@version", version);
+ long changeset = ElementData::CHANGESET_EMPTY;
+ changeset = properties.get("@changeset", changeset);
+ unsigned int timestamp = ElementData::TIMESTAMP_EMPTY;
+ timestamp = properties.get("@timestamp", timestamp);
+ std::string user = ElementData::USER_EMPTY.toStdString();
+ user = properties.get("@user", user);
+ long uid = ElementData::UID_EMPTY;
+ uid = properties.get("@uid", uid);
+
// Create an empty set of properties
pt::ptree empty;
// Construct Relation
- RelationPtr relation(new Relation(_defaultStatus, relation_id, _defaultCircErr));
+ RelationPtr relation(
+ new Relation(
+ _defaultStatus, relation_id, _defaultCircErr, "", changeset, version, timestamp,
+ QString::fromStdString(user), uid));
// Add the relation type and parse the roles
// NOTE: This may be empty which will cause errors later. If it is empty, we add a type
@@ -512,6 +559,7 @@ void OsmGeoJsonReader::_parseGeoJsonRelation(const string& id, const pt::ptree&
}
// Add tags
_addTags(properties, relation);
+ LOG_VART(relation);
// Add relation to map
_map->addRelation(relation);
@@ -694,7 +742,7 @@ vector<JsonCoordinates> OsmGeoJsonReader::_parseMultiGeometry(const pt::ptree& g
return results;
}
-void OsmGeoJsonReader::_addTags(const pt::ptree &item, const ElementPtr& element)
+void OsmGeoJsonReader::_addTags(const pt::ptree& item, const ElementPtr& element)
{
// Starts with the "properties" tree, use the "tags" subtree if it exists
// otherwise just use the "properties" tree as tags
@@ -705,17 +753,23 @@ void OsmGeoJsonReader::_addTags(const pt::ptree &item, const ElementPtr& element
for (pt::ptree::const_iterator tagIt = item.begin(); tagIt != item.end(); ++tagIt)
{
QString key = QString::fromStdString(tagIt->first).trimmed();
- QString value;
- if (tagIt->second.begin() != tagIt->second.end())
- value = QString::fromStdString(_parseSubTags(tagIt->second)).trimmed();
- else
- value = QString::fromStdString(tagIt->second.get_value<string>()).trimmed();
- element->setTag(key, value);
+ //LOG_VART(key);
+ // We've already parsed properties that have keys starting with '@' as metadata for the
+ // feature.
+ if (!key.startsWith("@"))
+ {
+ QString value;
+ if (tagIt->second.begin() != tagIt->second.end())
+ value = QString::fromStdString(_parseSubTags(tagIt->second)).trimmed();
+ else
+ value = QString::fromStdString(tagIt->second.get_value<string>()).trimmed();
+ element->setTag(key, value);
+ }
}
}
}
-string OsmGeoJsonReader::_parseSubTags(const pt::ptree &item)
+string OsmGeoJsonReader::_parseSubTags(const pt::ptree& item)
{
stringstream ss;
bool isObject = false;