Select to view content in your preferred language

Automating Parking Capacity Calculation and Updates for Shared GUIDs

551
2
Jump to solution
09-25-2023 02:09 PM
JacobWeston1
New Contributor

Hello!

Wondering if I could get some help with this rule.

"x.DBO.CapacityBlockface" - Contains a GUID field ['Blockface_GUID'] and a null count field ['Capacity'] to be populated by this rule.
"x.DBO.StreetParking" has a GUID field, ['Blockface_GUID,'] which is auto-populated by an attribute rule that identifies the nearest "CapacityBlockface" GUID through a buffer and intersect operation. Additionally, it includes a field called ['NumberCars'], which is populated by an attribute rule that calculates the number of cars that can fit within that segment.

 

What I would like this rule to do is - on the insert, update, or delete of a "StreetParking" feature, I want it to automatically calculate the number of available parking spots between all features that share a GUID. When it calculates the total, I want it to write to the "CapacityBlockface" feature that shares that GUID.

 

Example:
Three "StreetParking" segments (orange) contain different available parking based on length. They also contain the same GIUD (11E6 - last 4 of GUID) as the "CapacityBlockface" (white). On the insert, update, or delete of a "StreetParking" feature, I want the total number of cars between all that share a GUID to be pushed to the blockface feature field ['Capacity']. Therefore 11E6 will have 10 cars. 

Screenshot 2023-09-25 164944.png

Using this code, I can return the total number of cars through console, but I am running into issue when trying to return it to the "CapacityBlockface" layer. I get the error "Dictionary Type Expected"  on the GlobalID on line 18.

Any input would be greatly appreciated!!

 

var blockface = FeatureSetByName($datastore, "x.DBO.CapacityBlockface", ["Blockface_GUID", "Capacity", "GlobalID"], false)
var parking = FeatureSetByName($datastore,"x.DBO.StreetParking",["Blockface_GUID", "NumberCars"],false)

var parking_GUID = $feature.Blockface_GUID
var sql = 'Blockface_GUID LIKE @parking_GUID'

var masterFilter = Filter(parking,sql)

var countCars = 0
for(var i in masterFilter){
countCars += i.NumberCars
}

return {
    'edit': [{
        'className': "x.DBO.CapacityBlockface",
        'updates': [{
            'GlobalID': blockface.GlobalID,
            'attributes': {
                'Capacity': 'countCars'
            }
        }]
    }]
}

 

 

 

0 Kudos
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor
Blockface is a featureset, you need to filter it to get to a feature

View solution in original post

2 Replies
MikeMillerGIS
Esri Frequent Contributor
Blockface is a featureset, you need to filter it to get to a feature
JacobWeston1
New Contributor

Thank you Mike!

This is what I got working.

var blockface = FeatureSetByName($datastore, "x.DBO.CapacityBlockface", ["Blockface_GUID", "Capacity", "GlobalID"], false);
var parking = FeatureSetByName($datastore, "x.DBO.StreetParking", ["Blockface_GUID", "NumberCars"], false);

var parking_GUID = $feature.Blockface_GUID;
var sql = 'Blockface_GUID = @parking_GUID';

var filterParking = Filter(parking, sql);
var filterBlockface = Filter(blockface, sql);

var sumCars = 0;
for (var i in filterParking) {
    sumCars += i.NumberCars;
}

var filterblockface_GlobalID = "";
for (var i in filterBlockface) {
filterblockface_GlobalID = i.GlobalID;
}

return {
    'edit': [{
        'className': "x.DBO.CapacityBlockface",
        'updates': [{
            'GlobalID': filterblockface_GlobalID,
            'attributes': {
                'Capacity': sumCars
            }
        }]
    }]
};

 

0 Kudos