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

Add support for OGC API - Features Retriever #52

Merged
merged 12 commits into from
Nov 16, 2023
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -524,23 +524,65 @@ <h3 class="fs-subtitle">Angaben &uuml;ber den r&auml;umlichen Datensatz, aus dem
<div class="form-group">
<label>Datenquelltyp*</label>
<select ng-model="datasourceType"
ng-options="datasourceType as datasourceType.type for datasourceType in $ctrl.kommonitorImporterHelperServiceInstance.availableDatasourceTypes"
ng-options="datasourceType as datasourceType.type for datasourceType in availableDatasourceTypes track by datasourceType.type"
ng-change="onChangeDatasourceType(datasourceType)"
class="form-control" required>
<option disabled selected value> -- Quelltyp w&auml;hlen -- </option>
</select>
<div class="help-block with-errors"></div>
<div class="help-block"></div>
</div>

<div ng-show="datasourceType.type === 'FILE'">
<label>Datei*</label>
<input type="file" class="form-control" id="georesourceDataSourceInput_add" required></input>
</div>
<div ng-show="(datasourceType.type === 'OGCAPI_FEATURES')">
<label>Räumlicher Filter*</label>
<select id="datasourceTypeParameter_georesourceAdd_bboxType" ng-model="bboxType" class="form-control" required>
<option disabled selected value> -- Filter w&auml;hlen -- </option>
<option value="ref"> Referenzraumeinheit </option>
<option value="literal"> Manueller Begrenzungsrahmen </option>
</select>

<div ng-show="bboxType == 'ref'">
<!-- select available spatialUnits -->
<select id="datasourceTypeParameter_georesourceAdd_bboxRef"
ng-model="bboxRefSpatialUnit"
ng-options="spatialUnit.spatialUnitLevel for spatialUnit in availableSpatialUnits track by spatialUnit.spatialUnitId"
class="form-control" ng-required="bboxType == 'ref'">
<option disabled selected value> -- Raumeinheit w&auml;hlen -- </option>
</select>
<div class="help-block">
<p>Raumeinheit aus welchem ein umschließendes Rechteck extrahiert wird</p>
</div>
</div>
<div ng-show="bboxType == 'literal'">
<label>Begrenzungsrahmen*</label>
<input id="datasourceTypeParameter_georesourceAdd_bbox_minx" class="form-control" type="number" lang="us" placeholder="-180" ng-required="bboxType == 'literal'">
<div class="help-block">
<p>Minimale x-Koordinate</p>
</div>
<input id="datasourceTypeParameter_georesourceAdd_bbox_miny" class="form-control" type="number" lang="us" placeholder="-90" ng-required="bboxType == 'literal'">
<div class="help-block">
<p>Minimale y-Koordinate</p>
</div>
<input id="datasourceTypeParameter_georesourceAdd_bbox_maxx" class="form-control" type="number" lang="us" placeholder="180" ng-required="bboxType == 'literal'">
<div class="help-block">
<p>Maximale x-Koordinate</p>
</div>
<input id="datasourceTypeParameter_georesourceAdd_bbox_maxy" class="form-control" type="number" lang="us" placeholder="90" ng-required="bboxType == 'literal'">
<div class="help-block">
<p>Maximale y-Koordinate</p>
</div>
</div>
</div>
<div ng-show="! (datasourceType.type === 'FILE')">
<div ng-repeat="parameter in datasourceType.parameters">
<div ng-repeat="parameter in datasourceType.parameters | filter: { name: '!bbox' } ">
<div class="form-group">
<label>{{parameter.name}}*</label>
<label ng-if="parameter.mandatory">{{parameter.name}}*</label>
<label ng-if="!parameter.mandatory">{{parameter.name}}</label>
<textarea rows="1" id="datasourceTypeParameter_georesourceAdd_{{parameter.name}}"
class="form-control" placeholder="{{parameter.name}}" required></textarea>
class="form-control" placeholder="{{parameter.name}}" ng-required="parameter.mandatory"></textarea>
<div class="help-block">
<p>{{parameter.description}}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,33 @@ angular.module('georesourceEditFeaturesModal').component('georesourceEditFeature
$scope.georesourceEditFeaturesDataSourceInputInvalid = false;
$scope.georesourceDataSourceIdProperty = undefined;
$scope.georesourceDataSourceNameProperty = undefined;

$scope.availableDatasourceTypes = [];
$scope.availableSpatialUnits = undefined;

$scope.converter = undefined;
$scope.schema = undefined;
$scope.featureInfoText_singleFeatureAddMenu = undefined;
$scope.mimeType = undefined;
$scope.datasourceType = undefined;
$scope.georesourceDataSourceIdProperty = undefined;
$scope.georesourceDataSourceNameProperty = undefined;

$scope.converterDefinition = undefined;
$scope.datasourceTypeDefinition = undefined;
$scope.propertyMappingDefinition = undefined;
$scope.putBody_georesources = undefined;

$scope.validityEndDate_perFeature = undefined;
$scope.validityStartDate_perFeature = undefined;

$scope.attributeMapping_sourceAttributeName = undefined;
$scope.attributeMapping_destinationAttributeName = undefined;
$scope.attributeMapping_data = undefined;
$scope.attributeMapping_attributeType = kommonitorImporterHelperService.attributeMapping_attributeTypes[0];
$scope.attributeMappings_adminView = [];
$scope.keepAttributes = true;
$scope.keepMissingValues = true;
$scope.datasourceType = undefined;
$scope.georesourceDataSourceIdProperty = undefined;
$scope.georesourceDataSourceNameProperty = undefined;

$scope.converterDefinition = undefined;
$scope.datasourceTypeDefinition = undefined;
$scope.propertyMappingDefinition = undefined;
$scope.putBody_georesources = undefined;

$scope.validityEndDate_perFeature = undefined;
$scope.validityStartDate_perFeature = undefined;

$scope.attributeMapping_sourceAttributeName = undefined;
$scope.attributeMapping_destinationAttributeName = undefined;
$scope.attributeMapping_data = undefined;
$scope.attributeMapping_attributeType = kommonitorImporterHelperService.attributeMapping_attributeTypes[0];
$scope.attributeMappings_adminView = [];
$scope.keepAttributes = true;
$scope.keepMissingValues = true;

$scope.successMessagePart = undefined;
$scope.errorMessagePart = undefined;
Expand Down Expand Up @@ -499,6 +502,9 @@ angular.module('georesourceEditFeaturesModal').component('georesourceEditFeature
$scope.successMessagePart = undefined;
$scope.errorMessagePart = undefined;
$scope.importerErrors = undefined;

$scope.onChangeConverter();
$scope.onChangeDatasourceType();

$("#georesourceEditFeaturesSuccessAlert").hide();
$("#georesourceEditFeaturesErrorAlert").hide();
Expand All @@ -508,9 +514,26 @@ angular.module('georesourceEditFeaturesModal').component('georesourceEditFeature
}, 250);
};

$scope.onChangeConverter = function(){
$scope.schema = $scope.converter.schemas ? $scope.converter.schemas[0] : undefined;
$scope.mimeType = $scope.converter.mimeTypes[0];
$scope.onChangeConverter = function(schema){
if ($scope.converter) {
$scope.schema = $scope.converter.schemas ? $scope.converter.schemas[0] : undefined;
$scope.mimeType = $scope.converter.mimeTypes[0];

// update available datasourcetypes for this specific converter
$scope.availableDatasourceTypes = [];
for(var datasourceType of kommonitorImporterHelperService.availableDatasourceTypes){
for(var availableType of $scope.converter.datasources) {
if (datasourceType.type === availableType){
$scope.availableDatasourceTypes.push(datasourceType);
}
}
}

if ($scope.availableDatasourceTypes.length == 1) {
$scope.datasourceType = $scope.availableDatasourceTypes[0];
$scope.onChangeDatasourceType();
}
}
};

$scope.onChangeMimeType = function(mimeType){
Expand Down Expand Up @@ -644,6 +667,16 @@ angular.module('georesourceEditFeaturesModal').component('georesourceEditFeature

return true;
};

$scope.onChangeDatasourceType = function(ds){
if ($scope.datasourceType && $scope.datasourceType.type == "OGCAPI_FEATURES") {
$scope.availableSpatialUnits = [ ...kommonitorDataExchangeService.availableSpatialUnits_map.values() ]
// console.log($scope.availableSpatialUnits)
}
};

$scope.onChangeConverter();
$scope.onChangeDatasourceType();

$scope.buildImporterObjects = async function(){
$scope.converterDefinition = $scope.buildConverterDefinition();
Expand Down Expand Up @@ -840,96 +873,119 @@ angular.module('georesourceEditFeaturesModal').component('georesourceEditFeature
$scope.$digest();
}

$scope.converter = undefined;
$scope.converter = undefined;
for(var converter of kommonitorImporterHelperService.availableConverters){
if (converter.name === $scope.mappingConfigImportSettings.converter.name){
$scope.converter = converter;
if ($scope.mappingConfigImportSettings.converter && converter.name === $scope.mappingConfigImportSettings.converter.name){
$scope.converter = converter;
break;
}
}
}

$scope.schema = undefined;
if ($scope.converter && $scope.converter.schemas && $scope.mappingConfigImportSettings.converter.schema){
for (var schema of $scope.converter.schemas) {
if (schema === $scope.mappingConfigImportSettings.converter.schema){
$scope.schema = schema;
}
}
}

$scope.mimeType = undefined;
if ($scope.converter && $scope.converter.mimeTypes && $scope.mappingConfigImportSettings.converter.mimeType){
for (var mimeType of $scope.converter.mimeTypes) {
if (mimeType === $scope.mappingConfigImportSettings.converter.mimeType){
$scope.mimeType = mimeType;
}
}
}

$scope.datasourceType = undefined;
for(var datasourceType of kommonitorImporterHelperService.availableDatasourceTypes){
if (datasourceType.type === $scope.mappingConfigImportSettings.dataSource.type){
$scope.datasourceType = datasourceType;
break;
}
}

$scope.$digest();

// converter parameters
if ($scope.converter){
for (var convParameter of $scope.mappingConfigImportSettings.converter.parameters) {
$("#converterParameter_georesourceEditFeatures_" + convParameter.name).val(convParameter.value);
}
}

// datasourceTypes parameters
if ($scope.datasourceType){
for (var dsParameter of $scope.mappingConfigImportSettings.dataSource.parameters) {
$("#datasourceTypeParameter_georesourceEditFeatures_" + dsParameter.name).val(dsParameter.value);
}
}

// property Mapping
$scope.georesourceDataSourceNameProperty = $scope.mappingConfigImportSettings.propertyMapping.nameProperty;
$scope.georesourceDataSourceIdProperty = $scope.mappingConfigImportSettings.propertyMapping.identifierProperty;
$scope.validityStartDate_perFeature = $scope.mappingConfigImportSettings.propertyMapping.validStartDateProperty;
$scope.validityEndDate_perFeature = $scope.mappingConfigImportSettings.propertyMapping.validEndDateProperty;
$scope.keepAttributes = $scope.mappingConfigImportSettings.propertyMapping.keepAttributes;
$scope.keepMissingValues = $scope.mappingConfigImportSettings.propertyMapping.keepMissingOrNullValueAttributes;
$scope.attributeMappings_adminView = [];

for (var attributeMapping of $scope.mappingConfigImportSettings.propertyMapping.attributes) {
var tmpEntry = {
"sourceName": attributeMapping.name,
"destinationName": attributeMapping.mappingName
};

for (const dataType of kommonitorImporterHelperService.attributeMapping_attributeTypes) {
if (dataType.apiName === attributeMapping.type){
tmpEntry.dataType = dataType;
}
}

$scope.attributeMappings_adminView.push(tmpEntry);
}

if ($scope.mappingConfigImportSettings.periodOfValidity){
$scope.periodOfValidity = {};
$scope.periodOfValidity.startDate = $scope.mappingConfigImportSettings.periodOfValidity.startDate;
$scope.periodOfValidity.endDate = $scope.mappingConfigImportSettings.periodOfValidity.endDate;
$scope.periodOfValidityInvalid = false;

// update datePickers
if ($scope.periodOfValidity.startDate){
$("#georesourceEditFeaturesDatepickerStart").datepicker('setDate', $scope.periodOfValidity.startDate);
}
if ($scope.periodOfValidity.endDate){
$("#georesourceEditFeaturesDatepickerEnd").datepicker('setDate', $scope.periodOfValidity.endDate);
}
}

$scope.$digest();
$scope.schema = undefined;
if ($scope.converter && $scope.converter.schemas && $scope.mappingConfigImportSettings.converter.schema){
for (var schema of $scope.converter.schemas) {
if (schema === $scope.mappingConfigImportSettings.converter.schema){
$scope.schema = schema;
}
}
}

$scope.mimeType = undefined;
if ($scope.converter && $scope.converter.mimeTypes && $scope.mappingConfigImportSettings.converter.mimeType){
for (var mimeType of $scope.converter.mimeTypes) {
if (mimeType === $scope.mappingConfigImportSettings.converter.mimeType){
$scope.mimeType = mimeType;
}
}
}

$scope.datasourceType = undefined;
if ($scope.converter) {
for(var availableType of $scope.converter.datasources) {
for (var datasourceType of kommonitorImporterHelperService.availableDatasourceTypes) {
if (datasourceType.type === availableType){
$scope.availableDatasourceTypes.push(datasourceType);
var settings = $scope.mappingConfigImportSettings;
if (settings.dataSource && settings.dataSource.type === availableType) {
$scope.datasourceType = $scope.mappingConfigImportSettings.dataSource;
}
break;
}
}
}
}

$scope.onChangeConverter();
$scope.$digest();

// converter parameters
if ($scope.converter){
for (var convParameter of $scope.mappingConfigImportSettings.converter.parameters) {
$("#converterParameter_georesourceEditFeatures_" + convParameter.name).val(convParameter.value);
}
}

// datasourceTypes parameters
if ($scope.datasourceType){
for (var dsParameter of $scope.mappingConfigImportSettings.dataSource.parameters) {
if (dsParameter.name === "bbox") {
if ($("#datasourceTypeParameter_georesourceEditFeatures_bboxType").val() == "ref") {
$scope.bboxType = "ref";
$("#datasourceTypeParameter_georesourceEditFeatures_bboxRef").val(dsParameter.value)
} else {
$scope.bboxType = "literal";
var bbox = dsParameter.value.split(',');
$("#datasourceTypeParameter_georesourceEditFeatures_bbox_minx").val(bbox[0])
$("#datasourceTypeParameter_georesourceEditFeatures_bbox_miny").val(bbox[1])
$("#datasourceTypeParameter_georesourceEditFeatures_bbox_maxx").val(bbox[2])
$("#datasourceTypeParameter_georesourceEditFeatures_bbox_maxy").val(bbox[3])
}
} else {
$("#datasourceTypeParameter_georesourceEditFeatures_" + dsParameter.name).val(dsParameter.value);
}
}
}

// property Mapping
$scope.georesourceDataSourceNameProperty = $scope.mappingConfigImportSettings.propertyMapping.nameProperty;
$scope.georesourceDataSourceIdProperty = $scope.mappingConfigImportSettings.propertyMapping.identifierProperty;
$scope.validityStartDate_perFeature = $scope.mappingConfigImportSettings.propertyMapping.validStartDateProperty;
$scope.validityEndDate_perFeature = $scope.mappingConfigImportSettings.propertyMapping.validEndDateProperty;
$scope.keepAttributes = $scope.mappingConfigImportSettings.propertyMapping.keepAttributes;
$scope.keepMissingValues = $scope.mappingConfigImportSettings.propertyMapping.keepMissingOrNullValueAttributes;
$scope.attributeMappings_adminView = [];

for (var attributeMapping of $scope.mappingConfigImportSettings.propertyMapping.attributes) {
var tmpEntry = {
"sourceName": attributeMapping.name,
"destinationName": attributeMapping.mappingName
};

for (const dataType of kommonitorImporterHelperService.attributeMapping_attributeTypes) {
if (dataType.apiName === attributeMapping.type){
tmpEntry.dataType = dataType;
}
}

$scope.attributeMappings_adminView.push(tmpEntry);
}

if ($scope.mappingConfigImportSettings.periodOfValidity){
$scope.periodOfValidity = {};
$scope.periodOfValidity.startDate = $scope.mappingConfigImportSettings.periodOfValidity.startDate;
$scope.periodOfValidity.endDate = $scope.mappingConfigImportSettings.periodOfValidity.endDate;
$scope.periodOfValidityInvalid = false;

// update datePickers
if ($scope.periodOfValidity.startDate){
$("#georesourceEditFeaturesDatepickerStart").datepicker('setDate', $scope.periodOfValidity.startDate);
}
if ($scope.periodOfValidity.endDate){
$("#georesourceEditFeaturesDatepickerEnd").datepicker('setDate', $scope.periodOfValidity.endDate);
}
}

$scope.$digest();
};

$scope.onExportGeoresourceEditFeaturesMappingConfig = async function(){
Expand Down
Loading