Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tds domains #5760

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
eba4e05
initial
jordanmurray35 Jun 4, 2024
3b298d0
update makefile
jordanmurray35 Jun 4, 2024
a63c1d5
add config option
jordanmurray35 Jun 4, 2024
3ac4044
create tds thematic no coded schema
jordanmurray35 Jun 6, 2024
3acc804
update tds coded value translation
jordanmurray35 Jun 11, 2024
4ad980f
remove debug statements
jordanmurray35 Jun 11, 2024
2334890
update copyrights
jordanmurray35 Jun 12, 2024
f9cb343
add subtypes into TDS
jordanmurray35 Jul 2, 2024
0fc3a99
adding subtypes into tds schemas
jordanmurray35 Jul 2, 2024
63f874b
fix default values for certain features
jordanmurray35 Jul 10, 2024
a05ca2f
update expected output
jordanmurray35 Jul 15, 2024
d5f1198
update expected output
jordanmurray35 Jul 15, 2024
0b995b8
update expected test results
jordanmurray35 Jul 16, 2024
0185fdf
sonar debug
jordanmurray35 Jul 16, 2024
cff2260
sonar debug
jordanmurray35 Jul 16, 2024
4fb1471
sonar debug
jordanmurray35 Jul 16, 2024
2fa613c
sonar debug
jordanmurray35 Jul 16, 2024
94f460b
sonar debug
jordanmurray35 Jul 16, 2024
348b426
sonar debug
jordanmurray35 Jul 16, 2024
202caf1
sonar debug
jordanmurray35 Jul 16, 2024
44978f3
sonar debug
jordanmurray35 Jul 16, 2024
401feed
sonar debug
jordanmurray35 Jul 17, 2024
f75d279
sonar debug
jordanmurray35 Jul 17, 2024
b9cf5da
sonar debug
jordanmurray35 Jul 17, 2024
dfbe4ed
sonar debug
jordanmurray35 Jul 17, 2024
bcbc6e5
sonar debug
jordanmurray35 Jul 17, 2024
e701b93
sonar debug
jordanmurray35 Jul 17, 2024
23f5cfc
sonar debug
jordanmurray35 Jul 17, 2024
43e1dfc
remove debug statements
jordanmurray35 Jul 17, 2024
ec6b795
update expected results
jordanmurray35 Jul 17, 2024
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
7 changes: 6 additions & 1 deletion Makefile.hoot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SHELL=/bin/bash
.PHONY: clean-ccache HOOT_VERSION_FILE

# This list is for manually rebuilding the schema files. The files have been commited to the main GitHub repo
SCHEMA_FILES= translations/tds71_schema.js translations/tds70_schema.js translations/tds61_schema.js translations/tds40_schema.js translations/mgcp_schema.js translations/mgcp_thematic_schema.js translations/ggdm30_schema.js translations/tds71_thematic_schema.js translations/tds71_full_schema.js translations/tds61_full_schema.js translations/tds70_full_schema.js translations/tds40_full_schema.js translations/ggdm30_full_schema.js translations/etds71_rules.js translations/etds70_rules.js translations/etds61_rules.js translations/etds40_rules.js translations/emgcp_rules.js translations/eggdm30_rules.js translations/etds71_osm_rules.js translations/etds61_osm_rules.js translations/etds40_osm_rules.js translations/emgcp_osm_rules.js translations/eggdm30_osm_rules.js translations/etds70_osm_rules.js
SCHEMA_FILES= translations/tds71_schema.js translations/tds70_schema.js translations/tds61_schema.js translations/tds40_schema.js translations/mgcp_schema.js translations/mgcp_thematic_schema.js translations/ggdm30_schema.js translations/tds71_thematic_schema.js translations/tds71_thematic_enum_schema.js translations/tds71_full_schema.js translations/tds61_full_schema.js translations/tds70_full_schema.js translations/tds40_full_schema.js translations/ggdm30_full_schema.js translations/etds71_rules.js translations/etds70_rules.js translations/etds61_rules.js translations/etds40_rules.js translations/emgcp_rules.js translations/eggdm30_rules.js translations/etds71_osm_rules.js translations/etds61_osm_rules.js translations/etds40_osm_rules.js translations/emgcp_osm_rules.js translations/eggdm30_osm_rules.js translations/etds70_osm_rules.js


-include Makefile.inc
Expand Down Expand Up @@ -213,6 +213,11 @@ translations/tds71_thematic_schema.js: scripts/schema/ConvertTDSv71Schema_XML.py
mkdir -p $(@D)
$< --thematic $(word 2,$^) > $@ || (rm -f $@ ; exit -1)

# TDSv71 thematic schema with all of the text enumerations is built from and XML file made from a sample FGDB
translations/tds71_thematic_enum_schema.js: scripts/schema/ConvertTDSv71Schema_XML.py conf/translations/TDSv71.xml.gz
mkdir -p $(@D)
$< --nocodedvalues --thematic $(word 2,$^) > $@ || (rm -f $@ ; exit -1)

# TDSv71 schema is built from an XML file made from a sample FGDB
translations/tds71_schema.js: scripts/schema/ConvertTDSv71Schema_XML.py conf/translations/TDSv71.xml.gz
mkdir -p $(@D)
Expand Down
8 changes: 8 additions & 0 deletions conf/core/ConfigOptions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3639,6 +3639,14 @@ new file/layer.
When exporting, remove all non-spec attributes from the features. I.e. Do a "clean" export.
NOTE: This is destructive. It will drop data that is usually kept - OSMTAGS etc

=== ogr.coded.values

* Data Type: bool
* Default Value: `true`

When exporting, interpret all values to their coded value counterpart. When this value is false,
the value will be the human-readable value.

=== ogr.compare.output

* Data Type: bool
Expand Down
4 changes: 3 additions & 1 deletion hoot-core/src/main/cpp/hoot/core/io/OgrWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ void OgrWriter::_addFeature(OGRLayer* layer, const std::shared_ptr<Feature>& f,
const QVariant& v = it.value();
QByteArray ba = it.key().toUtf8();

//LOG_DEBUG("Current field: " << ba.constData());
//LOG_DEBUG("Current value: " << v.toString());

// If the field DOESN'T exist in the output layer, skip it.
if (poFeature->GetFieldIndex(ba.constData()) == -1)
{
Expand Down Expand Up @@ -696,7 +699,6 @@ void OgrWriter::_addFeature(OGRLayer* layer, const std::shared_ptr<Feature>& f,

vba.truncate(fieldWidth);
}

poFeature->SetField(ba.constData(), vba.constData());
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2018, 2019, 2020, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2024 Maxar (http://www.maxar.com/)
*/
#ifndef STRINGFIELDDEFINITION_H
#define STRINGFIELDDEFINITION_H
Expand All @@ -45,11 +45,15 @@ class StringFieldDefinition : public FieldDefinition
bool hasDefaultValue() const override;
QString toString() const override;

void addEnumeratedValue(QString v) {_enumeratedValues.insert(v); }
bool hasEnumeratedValue(QString v) { return _enumeratedValues.find(v) != _enumeratedValues.end(); }

void setDefaultValue(const QString& v) { _defaultValue = v; }

private:

QString _defaultValue;
std::set<QString> _enumeratedValues;
};

}
Expand Down
42 changes: 40 additions & 2 deletions hoot-js/src/main/cpp/hoot/js/schema/JavaScriptSchemaTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,41 @@ void JavaScriptSchemaTranslator::_parseEnumerations(std::shared_ptr<DoubleFieldD
}
}

void JavaScriptSchemaTranslator::_parseEnumerations(std::shared_ptr<StringFieldDefinition> fd, const QVariant& enumerations) const
{
if (enumerations.canConvert(QVariant::List) == false)
throw HootException("Expected enumerations to be an array of maps.");

QVariantList vl = enumerations.toList();

for (const auto& variant : qAsConst(vl))
{
if (variant.canConvert(QVariant::Map) == false)
throw HootException("Expected enumerations to be an array of maps.");

QVariantMap vm = variant.toMap();
if (vm["name"].canConvert(QVariant::String) == false)
throw HootException("Expected each enumeration map to contain a valid value.");

QString v = vm["name"].toString();

if (fd->hasEnumeratedValue(v))
{
if (logWarnCount < Log::getWarnMessageLimit())
{
LOG_WARN("Enumerated value repeated in enumerations table: " << v);
}
else if (logWarnCount == Log::getWarnMessageLimit())
{
LOG_WARN(className() << ": " << Log::LOG_WARN_LIMIT_REACHED_MESSAGE);
}
logWarnCount++;
}
else
fd->addEnumeratedValue(v);
}
}

void JavaScriptSchemaTranslator::_parseEnumerations(std::shared_ptr<IntegerFieldDefinition> fd,
const QVariant& enumerations) const
{
Expand Down Expand Up @@ -430,7 +465,7 @@ std::shared_ptr<FieldDefinition> JavaScriptSchemaTranslator::_parseFieldDefiniti
throw HootException("Error parsing type in column.");

QString type = map["type"].toString().toLower();
if (type == "string")
if (type == "string" || (type == "enumeration" && !ConfigOptions().getOgrCodedValues()))
{
std::shared_ptr<StringFieldDefinition> fd = std::make_shared<StringFieldDefinition>();

Expand All @@ -444,6 +479,10 @@ std::shared_ptr<FieldDefinition> JavaScriptSchemaTranslator::_parseFieldDefiniti
if (map.contains(MetadataTags::Length()))
fd->setWidth(_toInt32(map[MetadataTags::Length()]));

if (map.contains("enumerations"))
{
_parseEnumerations(fd, map["enumerations"]);
}
result = fd;
}
else if (type == "double" || type == "real")
Expand Down Expand Up @@ -582,7 +621,6 @@ std::shared_ptr<Layer> JavaScriptSchemaTranslator::_parseLayer(const QVariant& l
std::shared_ptr<FieldDefinition> fd = _parseFieldDefinition(variant);
if (names.find(fd->getName()) != names.end())
throw HootException("Found multiple fields with the same name. (" + fd->getName() + ")");

dfd->addField(fd);
names.insert(fd->getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2021, 2022 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2024 Maxar (http://www.maxar.com/)
*/

#ifndef JAVASCRIPT_SCHEMA_TRANSLATOR_H
Expand All @@ -45,6 +45,7 @@ namespace hoot

class FieldDefinition;
class Layer;
class StringFieldDefinition;
class DoubleFieldDefinition;
class IntegerFieldDefinition;
class LongIntegerFieldDefinition;
Expand Down Expand Up @@ -115,6 +116,7 @@ class JavaScriptSchemaTranslator : public ScriptSchemaTranslator,
std::vector<TranslatedFeature> _createAllFeatures(const QVariantList& vm) const;
std::shared_ptr<Feature> _createFeature(const QVariantMap& vm, QString& tableName) const;

void _parseEnumerations(std::shared_ptr<StringFieldDefinition> fd, const QVariant& enumerations) const;
void _parseEnumerations(std::shared_ptr<DoubleFieldDefinition> fd, const QVariant& enumerations) const;
void _parseEnumerations(std::shared_ptr<IntegerFieldDefinition> fd, const QVariant& enumerations) const;
void _parseEnumerations(std::shared_ptr<LongIntegerFieldDefinition> fd, const QVariant& enumerations) const;
Expand Down
Loading