Skip to content

Commit

Permalink
Merge pull request #2371 from finnishtransportagency/NextRelease
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
anttiahopeltositowise authored Dec 22, 2022
2 parents 8db6f6e + bcdec3f commit 72c2907
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 94 deletions.
9 changes: 5 additions & 4 deletions UI/src/assetTypeConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,14 +1022,15 @@
{label: 'Tien numero', type: 'read_only_number', publicId: "roadNumber", weight: 1, cssClass: 'road-number'},
{label: 'Tieosanumero', type: 'read_only_number', publicId: "roadPartNumber", weight: 2, cssClass: 'road-part-number'},
{label: 'Ajorata', type: 'read_only_number', publicId: "track", weight: 3, cssClass: 'track'},
{label: 'Etäisyys tieosan alusta', type: 'read_only_number', publicId: "startAddrMValue", weight: 4, cssClass: 'start-addr-m'},
{label: 'Etäisyys tieosan lopusta', type: 'read_only_number', publicId: "endAddrMValue", weight: 5, cssClass: 'end-addr-m'},
{label: 'Hallinnollinen Luokka', type: 'read_only_text', publicId: "administrativeClass", weight: 6, cssClass: 'admin-class'},
{label: 'Alkuetäisyys', type: 'read_only_number', publicId: "startAddrMValue", weight: 4, cssClass: 'start-addr-m'},
{label: 'Loppuetäisyys', type: 'read_only_number', publicId: "endAddrMValue", weight: 5, cssClass: 'end-addr-m'},
{label: 'Pituus', type: 'read_only_number', publicId: "addrLenght", weight: 6, cssClass: 'addr-lenght'},
{label: 'Hallinnollinen Luokka', type: 'read_only_text', publicId: "administrativeClass", weight: 7, cssClass: 'admin-class'},
{
label: 'Kaista', type: 'read_only_number', publicId: "lane_code", weight: 11, cssClass: 'lane-code'
},
{
label: 'Kaistan tyypi', required: 'required', type: 'single_choice', publicId: "lane_type",
label: 'Kaistan tyyppi', required: 'required', type: 'single_choice', publicId: "lane_type",
values: [
{id: 2, label: 'Ohituskaista'},
{id: 3, label: 'Kääntymiskaista oikealle'},
Expand Down
7 changes: 7 additions & 0 deletions UI/src/controller/laneModellingCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
});
};

self.getMainLaneByLinkIdAndSideCode = function(linkId, sideCode) {
return _.find(_.flatten(self.linearAssets), function(lane) {
var laneCode = _.head(Property.getPropertyByPublicId(lane.properties, 'lane_code').values).value;
return lane.linkId === linkId && laneCode === 1 && lane.sideCode === sideCode;
});
};

self.fetchViewOnlyLanes = function(boundingBox, zoom) {
return backend.getViewOnlyLanesByBoundingBox(boundingBox, zoom, isWalkingCyclingActive).then(function(lanes) {
eventbus.trigger('fetchedViewOnly', lanes);
Expand Down
31 changes: 31 additions & 0 deletions UI/src/model/selectedLaneModelling.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@
return !_.isUndefined(lane);
};

this.isLaneFullLinkLength = function(lane) {
var selectedMainLane = self.getLane(1);
return lane.startMeasure !== selectedMainLane.startMeasure || lane.endMeasure !== selectedMainLane.endMeasure;
};

this.haveNewLane = function () {
return _.some(self.selection, function(lane){
return lane.id === 0;
Expand Down Expand Up @@ -359,6 +364,32 @@
return getProperty(self.getLane(laneNumber, marker), 'properties');
};

// Calculate accurate road address start and end m-values for additional lane. Get road link measures from main lane.
this.getAddressValuesForCutLane = function(lane) {
var mainLane = collection.getMainLaneByLinkIdAndSideCode(lane.linkId, lane.sideCode);
var roadLinkLength = mainLane.endMeasure;
var roadAddressSideCode = mainLane.roadAddressSideCode;

// A coefficient is needed because road address and geometry lengths don't match exactly. Coefficient tells
// how long is '1 road address meter' on current link's geometry
var coefficient = (mainLane.endAddrMValue - mainLane.startAddrMValue) / roadLinkLength;

// If road address side code is towards digitizing(2) startAddrMValue points to lane's start measure (southern end-point)
// and endAddrMValue points to lane's end measure (northern end-point)
if (roadAddressSideCode === 2) {
lane.startAddrMValue = mainLane.startAddrMValue + Math.round(lane.startMeasure * coefficient);
lane.endAddrMValue = mainLane.startAddrMValue + Math.round(lane.endMeasure * coefficient);
}
// If road address side code is against digitizing(3) startAddrMValue points to lane's end measure (northern end-point)
// and endAddrMValue points to lane's start measure (southern point)
else if (roadAddressSideCode === 3) {
lane.endAddrMValue = mainLane.endAddrMValue - Math.round(lane.startMeasure * coefficient);
lane.startAddrMValue = mainLane.endAddrMValue - Math.round(lane.endMeasure * coefficient);
}

return lane;
};

this.setNewLane = function(laneNumber) {
var laneToClone;
if(laneNumber == 2){
Expand Down
50 changes: 37 additions & 13 deletions UI/src/view/linear_asset/laneModellingForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,29 @@
{label: 'Tien numero', type: 'read_only_number', publicId: "roadNumber", weight: 1, cssClass: 'road-number'},
{label: 'Tieosanumero', type: 'read_only_number', publicId: "roadPartNumber", weight: 2, cssClass: 'road-part-number'},
{label: 'Ajorata', type: 'read_only_number', publicId: "track", weight: 3, cssClass: 'track'},
{label: 'Etäisyys tieosan alusta', type: 'read_only_number', publicId: "startAddrMValue", weight: 4, cssClass: 'start-addr-m'},
{label: 'Etäisyys tieosan lopusta', type: 'read_only_number', publicId: "endAddrMValue", weight: 5, cssClass: 'end-addr-m'},
{label: 'Hallinnollinen Luokka', type: 'read_only_text', publicId: "administrativeClass", weight: 6, cssClass: 'admin-class'},
{label: 'Kaista', type: 'read_only_number', publicId: "lane_code", weight: 11, cssClass: 'lane-code'},
{label: 'Alkuetäisyys', type: 'read_only_number', publicId: "startAddrMValue", weight: 4, cssClass: 'start-addr-m'},
{label: 'Loppuetäisyys', type: 'read_only_number', publicId: "endAddrMValue", weight: 5, cssClass: 'end-addr-m'},
{label: 'Pituus', type: 'read_only_number', publicId: "addrLenght", weight: 6, cssClass: 'addr-lenght'},
{label: 'Hallinnollinen Luokka', type: 'read_only_text', publicId: "administrativeClass", weight: 7, cssClass: 'admin-class'},
{label: 'Kaista', type: 'read_only_number', publicId: "lane_code", weight: 12, cssClass: 'lane-code'},
{
label: 'Kaistan tyypi', required: 'required', type: 'single_choice', publicId: "lane_type", defaultValue: "1", weight: 12,
label: 'Kaistan tyyppi', required: 'required', type: 'single_choice', publicId: "lane_type", defaultValue: "1", weight: 13,
values: [
{id: 1, label: 'Pääkaista'}
]
},
{
label: 'Alkupvm', type: 'date', publicId: "start_date", weight: 13, required: true
label: 'Alkupvm', type: 'date', publicId: "start_date", weight: 14, required: true
}
]
};

var roadAddressFormStructure = {
fields : [
{label: 'Osa', required: 'required', type: 'number', publicId: "startRoadPartNumber", weight: 7},
{label: 'Etäisyys', required: 'required', type: 'number', publicId: "startDistance", weight: 8},
{label: 'Osa', required: 'required', type: 'number', publicId: "endRoadPartNumber", weight: 9},
{label: 'Etäisyys', required: 'required', type: 'number', publicId: "endDistance", weight: 10}
{label: 'Osa', required: 'required', type: 'number', publicId: "startRoadPartNumber", weight: 8},
{label: 'Etäisyys', required: 'required', type: 'number', publicId: "startDistance", weight: 9},
{label: 'Osa', required: 'required', type: 'number', publicId: "endRoadPartNumber", weight: 10},
{label: 'Etäisyys', required: 'required', type: 'number', publicId: "endDistance", weight: 11}
]
};

Expand Down Expand Up @@ -268,6 +269,11 @@
var publicId = field.publicId;
var hasRoadAddress = hasRoadAddressInfo(selectedLinks);

// If lane has road address info and is cut, use lane's calculated road address start and end m-values
// Multiple lane selection for cut lanes is not supported currently and thus chaining road address values for cut lanes is not needed.
var assetHasRoadAddressAndCut = hasRoadAddress && lanesAssets.isLaneFullLinkLength(asset);
if(assetHasRoadAddressAndCut) lanesAssets.getAddressValuesForCutLane(asset);

switch (publicId) {
case "roadNumber":
case "roadPartNumber":
Expand All @@ -276,17 +282,35 @@
}
break;
case "startAddrMValue":
if (hasRoadAddress) {
if (assetHasRoadAddressAndCut) {
value = asset.startAddrMValue;
}
else if (hasRoadAddress) {
roadPartNumber = Math.min.apply(null, _.compact(Property.pickUniqueValues(selectedLinks, 'roadPartNumber')));
value = Math.min.apply(null, Property.chainValuesByPublicIdAndRoadPartNumber(selectedLinks, roadPartNumber, publicId));
}
break;
case "endAddrMValue":
if (hasRoadAddress) {
if (assetHasRoadAddressAndCut) {
value = asset.endAddrMValue;
}
else if (hasRoadAddress) {
roadPartNumber = Math.max.apply(null, _.compact(Property.pickUniqueValues(selectedLinks, 'roadPartNumber')));
value = Math.max.apply(null, Property.chainValuesByPublicIdAndRoadPartNumber(selectedLinks, roadPartNumber, publicId));
}
break;
case "addrLenght":
if (assetHasRoadAddressAndCut) {
value = asset.endAddrMValue - asset.startAddrMValue;
}
else if (hasRoadAddress) {
var startRoadPartNumber = Math.min.apply(null, _.compact(Property.pickUniqueValues(selectedLinks, 'roadPartNumber')));
var endRoadPartNumber = Math.max.apply(null, _.compact(Property.pickUniqueValues(selectedLinks, 'roadPartNumber')));
var selectionStartAddrM = Math.min.apply(null, Property.chainValuesByPublicIdAndRoadPartNumber(selectedLinks, startRoadPartNumber, "startAddrMValue"));
var selectionEndAddrM = Math.max.apply(null, Property.chainValuesByPublicIdAndRoadPartNumber(selectedLinks, endRoadPartNumber, "endAddrMValue"));
value = selectionEndAddrM - selectionStartAddrM;
}
break;
case "administrativeClass":
value = administrativeClassValues[_.head(selectedLinks)[publicId]];
break;
Expand Down Expand Up @@ -751,7 +775,7 @@

var newLaneStructure = function (laneNumber) {
var indexOfProperty = _.findIndex(defaultFormStructure.fields, {'publicId': 'lane_code'});
defaultFormStructure.fields[indexOfProperty] = {label: 'Kaista', type: 'read_only_number', publicId: "lane_code", defaultValue: laneNumber, weight: 11};
defaultFormStructure.fields[indexOfProperty] = {label: 'Kaista', type: 'read_only_number', publicId: "lane_code", defaultValue: laneNumber, weight: 12};
currentFormStructure = defaultFormStructure;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ class Digiroad2Api(val roadLinkService: RoadLinkService,
"track" -> lane.attributes.get("TRACK"),
"startAddrMValue" -> lane.attributes.get("START_ADDR"),
"endAddrMValue" -> lane.attributes.get("END_ADDR"),
"roadAddressSideCode" -> lane.attributes.get("SIDECODE"),
"administrativeClass" -> lane.administrativeClass.value,
"linkType" -> lane.attributes.getOrElse("linkType", 99),
"constructionType" -> lane.attributes.getOrElse("constructionType", 99)
Expand Down
Loading

0 comments on commit 72c2907

Please sign in to comment.