|
POST
|
We have played around doing this in Arcade and an attribute rule. Here is the code if you want to try it out. function find_closest_line() {
var line_class = FeatureSetByName($datastore, "line", ["objectid"], true);
//var candidates = Intersects(line_class, Buffer($feature, 500, "miles"));
var candidates = line_class;
var shortest = [1e10, null];
for (var line in candidates) {
var d = Distance($feature, line)
if (d < shortest[0]) shortest = [d, line]
}
return shortest[-1]
}
function point_and_distance(point_feature, other_feature) {
/*
finds the closest point from point_feature to other_feature
Args:
point_feature: Point Geometry
other_feature: Point/Line/Polygon Geometry
Returns: dictionary
{distance: number, // distance from point_feature to closest point
point: geometry, // the coordinate pair of the closest point
isVertex: bool} // if the closest point is a vertex of other_feature
*/
var point_feature = Geometry(point_feature);
var other_feature = Geometry(other_feature);
var shape = TypeOf(other_feature);
var vertices;
if (shape == 'Point') {
return {"distance": Distance(point_feature, other_feature),
"coordinates": [other_feature["x"], other_feature["y"]],
"isVertex": true}
}
else if (shape == 'Multipoint') {
var points = other_feature["points"];
var shortest = [1e10, null];
for (var i in points) {
var p = points[i]
var dist = Distance(point_feature, p);
if (dist < shortest[0]) shortest = [dist, [p["x"], p["y"]]]
}
return {"distance": shortest[0],
"coordinates": shortest[1],
"isVertex": true}
}
else if (shape == 'Polyline') vertices = other_feature["paths"]
else if (shape == 'Polygon') vertices = other_feature["rings"]
else return null
var x = point_feature["x"];
var y = point_feature["y"];
// Loop through each part of the geometry and each segment, tracking the shortest distance
var shortest = [1e10];
for (var i in vertices) {
var part = vertices[i];
var previous = part[0];
for (var j = 1; j < Count(part); j++) {
var current = part[j];
var result = pDistance(x, y, previous["x"], previous["y"], current["x"], current["y"]);
if (result[0] < shortest[0]) shortest = result
previous = current;
}
}
// Couldn't find anything
if (Count(shortest) == 1) return null
return {"distance": shortest[0],
"coordinates": shortest[1],
"isVertex": shortest[2]}
}
function pDistance(x, y, x1, y1, x2, y2) {
// adopted from https://stackoverflow.com/a/6853926
var A = x - x1;
var B = y - y1;
var C = x2 - x1;
var D = y2 - y1;
var dot = A * C + B * D;
var len_sq = C * C + D * D;
var param = -1;
if (len_sq != 0) //in case of 0 length line
param = dot / len_sq;
var xx, yy;
var is_vertex = true;
if (param < 0) {
xx = x1;
yy = y1;
}
else if (param > 1) {
xx = x2;
yy = y2;
}
else {
is_vertex = false;
xx = x1 + param * C;
yy = y1 + param * D;
}
var dx = x - xx;
var dy = y - yy;
return [Sqrt(dx * dx + dy * dy), [xx, yy], is_vertex];
}
function create_line(start, end_coordinates) {
var geo = Geometry(start);
return Polyline({"paths": [[[geo["x"], geo["y"]], end_coordinates]], "spatialReference": geo["spatialReference"]})
}
var closest = find_closest_line();
if (closest == null) return null
var data = point_and_distance($feature, closest);
if (data == null) return null
var lateral = create_line($feature, data["coordinates"]);
return {"result": null,
"edit": [{
"className": "lateral", "adds": [{"geometry": lateral}]
}
]
}
... View more
03-31-2022
03:06 AM
|
3
|
1
|
1549
|
|
BLOG
|
Brian, In the blog, there is a section for using the widget with enterprise - https://www.esri.com/arcgis-blog/products/utility-network/mapping/configure-apps-to-trace-a-utility-network/#:~:text=To%20trace%20a%20utility%20network%20with%20maps%20from%20your%20ArcGIS%20Enterprise%20Portal. Once the widget is out of beta, the next version of ArcGIS Enterprise will include it as part of the install.
... View more
03-30-2022
02:41 AM
|
2
|
0
|
1633
|
|
POST
|
You could use the https://developers.arcgis.com/arcade/function-reference/geometry_functions/#equals function to compare Geo instead of a text comparison.
... View more
03-25-2022
01:49 AM
|
0
|
1
|
5885
|
|
POST
|
If you do the same process to a Mobile or File GDB, does it succeed? In the asset package folder, there is a ap_workspace folder, can you send me the gp log file? Could you send a schema only asset packge or UN that I can try to repo the issue? [email protected] What version of postgres are you on?
... View more
03-24-2022
05:39 AM
|
0
|
0
|
2795
|
|
POST
|
I do not think this is possible. We have modeled Lights in the electrical domain so allow tracing the electric lines to get to lights. You could model the light system as just a different subnetwork in electric. You could also model an association from the electric node to the streetlight, that might work.
... View more
03-24-2022
03:56 AM
|
0
|
1
|
1482
|
|
POST
|
I am not sure what is going on here. Something is not being applied correctly. Did you start with a new postgres gdb or was this an existing GDB? I see you have maps open, we have seen where these create locks on the Utility Network and cause corruption. Can you close all the maps, restart pro and apply the asset package to a new Postgres database?
... View more
03-24-2022
03:52 AM
|
0
|
6
|
2799
|
|
POST
|
I have recreated that rule to not use buffer. There are disabled rules, the Auto_Contain_By_Rules that also will not work now. I have rewrote them to not use buffer, but found that Distance is now blocked on projected systems. If you need these rules, I will look at how to rewrite distance for you.
... View more
03-24-2022
03:49 AM
|
1
|
0
|
1162
|
|
POST
|
I narrowed it down to Buffer, not angle. This worked on my 2.8.4 machine, but did not work on my 2.9.2 machine. I will post an update if I learn more.
... View more
03-23-2022
11:02 AM
|
0
|
0
|
2184
|
|
POST
|
The rule is calling Angle, I am testing to see if angle ever worked on a geographic system.
... View more
03-23-2022
10:17 AM
|
0
|
0
|
2229
|
|
POST
|
If you have an active edit session, it should work. When there is an active edit session, the backend logic pulls all the fields.
... View more
03-23-2022
10:16 AM
|
0
|
0
|
2229
|
|
POST
|
I did find a bug for the issue if you want to follow https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDE0NTc2MA==
... View more
03-23-2022
10:07 AM
|
0
|
2
|
2918
|
|
POST
|
AR = Attribute Rule, sorry for the abbreviation Looking at the script, it does not. Only fields it is updating. The core script would need to be modified. MikeMillerGIS_0-1648053963872.png
... View more
03-23-2022
09:46 AM
|
0
|
1
|
2920
|
|
POST
|
There is an issue when you use a cursor on a class with attribute rules. You need to make sure all the fields in the AR are in the fields list for the cursor.
... View more
03-23-2022
09:19 AM
|
0
|
1
|
2940
|
|
POST
|
Make sure the file extension is lower case csv, not CSV. There is a bug where it is treating CSV as a dbf file
... View more
03-23-2022
08:05 AM
|
4
|
1
|
1929
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 2 weeks ago | |
| 1 | 3 weeks ago | |
| 2 | 07-07-2026 06:45 AM | |
| 1 | 06-26-2026 09:15 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|