<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ADMS 2.0 Create Address Point - Z-value error in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1323922#M1090</link>
    <description>&lt;P&gt;It is a lot easier to read code if you post it as a code snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you post a screen shot like below for&amp;nbsp;SiteAddressPointsMSD&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MikeMillerGIS_1-1693408488455.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/79467i54C85DC2346079AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MikeMillerGIS_1-1693408488455.png" alt="MikeMillerGIS_1-1693408488455.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2023 15:15:26 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2023-08-30T15:15:26Z</dc:date>
    <item>
      <title>ADMS 2.0 Create Address Point - Z-value error</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1323916#M1089</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I'm currently working on the attribute rules in the address data management solution 2.0. The address point rule "Create Site Address Point" gives me the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="masslc_0-1693407734323.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/79465i8ABD4FBB8E3819BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="masslc_0-1693407734323.png" alt="masslc_0-1693407734323.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For my original Address Point feature layer, the attribute Shape, is&amp;nbsp; classed as Point Z. From my understanding this should work with the new ADMS 2.0 solution but just in case I created a duplicate layer that has an attribute Shape as point. I still get the same error though.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;// This rule will create a new site address point when an address point is created along a road&lt;/P&gt;&lt;P&gt;// The site address point will be offset from the road by the distance and direction defined in the address point feature template&lt;/P&gt;&lt;P&gt;// Define the Address Points fields&lt;BR /&gt;var id_field = "addressptid";&lt;BR /&gt;var offdist_field = "offdist";&lt;BR /&gt;var offdir_field = "offdir";&lt;BR /&gt;var numpoints_field = "numpoints";&lt;BR /&gt;var incrementval_field = "incrementval";&lt;BR /&gt;var capturemeth_field = "capturemeth";&lt;/P&gt;&lt;P&gt;// Define the Site Addresses fields, , does the first line need to be addressptid or addressid?&lt;BR /&gt;// And do we need to relate the addressptid column in address points to site points?&lt;BR /&gt;var addressptid_field = "addressid";&lt;BR /&gt;var addrnum_field = "housenumber";&lt;BR /&gt;var roadfullname_field = "fullname";&lt;BR /&gt;var status_field = "status";&lt;BR /&gt;var defaultstatus = "Pending";&lt;BR /&gt;var addrcapturemeth_field = "capturemethod";&lt;/P&gt;&lt;P&gt;// Define the Road Centerline fields&lt;BR /&gt;var fromleft_field = "fromaddr_l";&lt;BR /&gt;var fromright_field = "fromaddr_r";&lt;BR /&gt;var toleft_field = "toaddr_l";&lt;BR /&gt;var toright_field = "toaddr_r";&lt;BR /&gt;var fullname_field = "fullname";&lt;/P&gt;&lt;P&gt;// This function will return the new point offset perpendicularly from a 2-point line segment at a specified distance&lt;BR /&gt;// Positive distance is to the left of the line. Negative distance is to the right of the line&lt;BR /&gt;function offsetPoint(firstPoint, secondPoint, fromPoint, dist) {&lt;BR /&gt;var x1 = firstPoint.x;&lt;BR /&gt;var y1 = firstPoint.y;&lt;BR /&gt;var x2 = secondPoint.x;&lt;BR /&gt;var y2 = secondPoint.y;&lt;BR /&gt;var x3 = fromPoint.x;&lt;BR /&gt;var y3 = fromPoint.y;&lt;/P&gt;&lt;P&gt;var a = y1 - y2;&lt;BR /&gt;var b = x2 - x1;&lt;/P&gt;&lt;P&gt;var norm = Sqrt(a*a + b*b);&lt;BR /&gt;a = a / norm;&lt;BR /&gt;b = b / norm;&lt;/P&gt;&lt;P&gt;return [x3 + a * dist, y3 + b * dist]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will find the closest point on line_feature from point_feature&lt;BR /&gt;function closestPointInfo(point_feature, line_feature) {&lt;BR /&gt;var vertices = line_feature["paths"]&lt;BR /&gt;var x = point_feature["x"];&lt;BR /&gt;var y = point_feature["y"];&lt;/P&gt;&lt;P&gt;// Loop through each part of the geometry and each segment, tracking the shortest distance&lt;BR /&gt;var shortest = [1e10];&lt;BR /&gt;for (var i in vertices) {&lt;BR /&gt;var part = vertices[i];&lt;BR /&gt;var previous = part[0];&lt;BR /&gt;for (var j = 1; j &amp;lt; Count(part); j++) {&lt;BR /&gt;var current = part[j];&lt;BR /&gt;var result = pDistance(x, y, previous["x"], previous["y"], current["x"], current["y"]);&lt;BR /&gt;if (result[0] &amp;lt; shortest[0]) shortest = result&lt;BR /&gt;previous = current;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// Couldn't find anything&lt;BR /&gt;if (Count(shortest) == 1) return null&lt;/P&gt;&lt;P&gt;return {"distance": shortest[0],&lt;BR /&gt;"coordinates": shortest[1],&lt;BR /&gt;"isVertex": shortest[2],&lt;BR /&gt;"lineSide": shortest[3]}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will find the closest point on line_feature from point_feature&lt;BR /&gt;function closestPointInfo(point_feature, line_feature) {&lt;BR /&gt;var vertices = line_feature["paths"]&lt;BR /&gt;var x = point_feature["x"];&lt;BR /&gt;var y = point_feature["y"];&lt;/P&gt;&lt;P&gt;// Loop through each part of the geometry and each segment, tracking the shortest distance&lt;BR /&gt;var shortest = [1e10];&lt;BR /&gt;for (var i in vertices) {&lt;BR /&gt;var part = vertices[i];&lt;BR /&gt;var previous = part[0];&lt;BR /&gt;for (var j = 1; j &amp;lt; Count(part); j++) {&lt;BR /&gt;var current = part[j];&lt;BR /&gt;var result = pDistance(x, y, previous["x"], previous["y"], current["x"], current["y"]);&lt;BR /&gt;if (result[0] &amp;lt; shortest[0]) shortest = result&lt;BR /&gt;previous = current;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// Couldn't find anything&lt;BR /&gt;if (Count(shortest) == 1) return null&lt;/P&gt;&lt;P&gt;return {"distance": shortest[0],&lt;BR /&gt;"coordinates": shortest[1],&lt;BR /&gt;"isVertex": shortest[2],&lt;BR /&gt;"lineSide": shortest[3]}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will get distance between 2 points&lt;BR /&gt;function pDistance(x, y, x1, y1, x2, y2) {&lt;BR /&gt;var A = x - x1;&lt;BR /&gt;var B = y - y1;&lt;BR /&gt;var C = x2 - x1;&lt;BR /&gt;var D = y2 - y1;&lt;/P&gt;&lt;P&gt;var dot = A * C + B * D;&lt;BR /&gt;var len_sq = C * C + D * D;&lt;BR /&gt;var param = -1;&lt;BR /&gt;if (len_sq != 0) //in case of 0 length line&lt;BR /&gt;param = dot / len_sq;&lt;/P&gt;&lt;P&gt;var xx, yy;&lt;BR /&gt;var is_vertex = true;&lt;BR /&gt;if (param &amp;lt; 0) {&lt;BR /&gt;xx = x1;&lt;BR /&gt;yy = y1;&lt;BR /&gt;}&lt;BR /&gt;else if (param &amp;gt; 1) {&lt;BR /&gt;xx = x2;&lt;BR /&gt;yy = y2;&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;is_vertex = false;&lt;BR /&gt;xx = x1 + param * C;&lt;BR /&gt;yy = y1 + param * D;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;var dx = x - xx;&lt;BR /&gt;var dy = y - yy;&lt;BR /&gt;return [Sqrt(dx * dx + dy * dy), [xx, yy], is_vertex, sideOfLine(x,y,x1,y1,x2,y2)];&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will get side of line segment that a point (x, y) is on based on the direction of segment [[x1, y1], [x2, y2]]&lt;BR /&gt;function sideOfLine(x, y, x1, y1, x2, y2) {&lt;/P&gt;&lt;P&gt;var d = (x - x1) * (y2 - y1) - (y - y1) * (x2 - x1)&lt;BR /&gt;if (d &amp;lt; 0) {&lt;BR /&gt;return 'Left'&lt;BR /&gt;} else if (d &amp;gt; 0) {&lt;BR /&gt;return 'Right'&lt;BR /&gt;} else {&lt;BR /&gt;return null&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will create point geometry from coordinates [x, y]&lt;BR /&gt;function createPoint(coordinates, spatial_ref) {&lt;BR /&gt;return Point({"x": coordinates[0], "y": coordinates[1], "z" : 0, "spatialReference": spatial_ref})&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will return the segment intersected and the distance along the line&lt;BR /&gt;function intersectDistanceAlong(sourceGeometry, interestedLine){&lt;BR /&gt;var distanceAlongLine = 0;&lt;BR /&gt;// Loop through the segments of the line. Handle multipart geometries&lt;BR /&gt;for (var part in Geometry(interestedLine).paths) {&lt;BR /&gt;var segment = Geometry(interestedLine).paths[part];&lt;/P&gt;&lt;P&gt;// Loop through the points in the segment&lt;BR /&gt;for (var i in segment) {&lt;BR /&gt;if (i == 0) continue;&lt;/P&gt;&lt;P&gt;// Construct a 2-point line segment from the current and previous point&lt;BR /&gt;var firstPoint = segment[i-1];&lt;BR /&gt;var secondPoint = segment[i]&lt;BR /&gt;var twoPointLine = Polyline({ 'paths' : [[[firstPoint.x, firstPoint.y], [secondPoint.x, secondPoint.y]]], 'spatialReference' : firstPoint.spatialReference});&lt;/P&gt;&lt;P&gt;// Test if the point intersects the 2-point line segment&lt;BR /&gt;if (Intersects(sourceGeometry, twoPointLine)) {&lt;BR /&gt;// Construct a 2-point line segment using the previous point and the address point&lt;BR /&gt;var lastSegment = Polyline({ 'paths' : [[[firstPoint.x, firstPoint.y], [sourceGeometry.x, sourceGeometry.y]]], 'spatialReference' : firstPoint.spatialReference});&lt;BR /&gt;// Add to the total distance along the line and break the loop&lt;BR /&gt;distanceAlongLine += Length(lastSegment);&lt;BR /&gt;return [twoPointLine, distanceAlongLine]&lt;BR /&gt;}&lt;BR /&gt;// Add to the toal distance along the line&lt;BR /&gt;distanceAlongLine += Length(twoPointLine);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// This function will return the address number of the new site address point&lt;BR /&gt;// It determines this based on the from and to address range on the intersecting road and the direction of the offset&lt;BR /&gt;function getAddrNum(road, percentAlong, dir) {&lt;BR /&gt;var addrNum = null;&lt;BR /&gt;var from = road[fromleft_field];&lt;BR /&gt;var to = road[toleft_field];&lt;BR /&gt;if (Lower(dir) == 'right') {&lt;BR /&gt;var from = road[fromright_field];&lt;BR /&gt;var to = road[toright_field];&lt;BR /&gt;}&lt;BR /&gt;if (from == null || to == null) return null;&lt;BR /&gt;var val = percentAlong * (to - from);&lt;BR /&gt;var addrNum = 0;&lt;BR /&gt;&lt;BR /&gt;if ((Floor(val) % 2) == 0) addrNum = Floor(val);&lt;BR /&gt;else if ((Ceil(val) % 2) == 0) addrNum = Ceil(val);&lt;BR /&gt;else addrNum = Floor(val) - 1;&lt;BR /&gt;&lt;BR /&gt;return from + addrNum;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;If (!HasKey($feature, id_field)) return;&lt;BR /&gt;var id = $feature[id_field];&lt;/P&gt;&lt;P&gt;// Get the geometry of the feature&lt;BR /&gt;var geom = Geometry($feature);&lt;/P&gt;&lt;P&gt;// Get the distance and direction defined in the address point feature template/&lt;BR /&gt;// If none specified defaults to 0 and Left&lt;BR /&gt;var dist = 0;&lt;BR /&gt;if ($feature[offdist_field] != null) dist = $feature[offdist_field];&lt;BR /&gt;var dir = 'Left';&lt;BR /&gt;if ($feature[offdir_field] != null) dir = $feature[offdir_field];&lt;BR /&gt;if (Lower(dir) == 'right') dist *= -1&lt;/P&gt;&lt;P&gt;// Get the number of site address points and increment value from the address point feature template&lt;BR /&gt;// Defaults to 1 and 0 respectively&lt;BR /&gt;var numpoints = 1;&lt;BR /&gt;if ($feature[numpoints_field] != null) numpoints = $feature[numpoints_field];&lt;BR /&gt;var increment = 0;&lt;BR /&gt;if ($feature[incrementval_field] != null) increment = $feature[incrementval_field];&lt;BR /&gt;&lt;BR /&gt;// If not creating any site addresses return&lt;BR /&gt;if (numpoints &amp;lt; 1) return;&lt;/P&gt;&lt;P&gt;// Find any intersecting roads with the address point&lt;BR /&gt;// If no roads intersect, buffer the point to handle cases where point isn't exactly snapped to line and try again&lt;BR /&gt;// If no roads intersect the the buffer return an error message and prevent the address point from being created&lt;BR /&gt;var intersectingRoads = Intersects(FeatureSetByName($datastore, "CenterlinesMSD", [fullname_field, fromleft_field, toleft_field, fromright_field, toright_field], true), geom);&lt;BR /&gt;if (Count(intersectingRoads) == 0) {&lt;BR /&gt;intersectingRoads = Intersects(FeatureSetByName($datastore, "CenterlinesMSD", [fullname_field, fromleft_field, toleft_field, fromright_field, toright_field], true), Buffer(geom, 5));&lt;BR /&gt;if (Count(intersectingRoads) == 0) return { "errorMessage": "Address Point must intersect at least one Road Centerline" }&lt;BR /&gt;}&lt;BR /&gt;var intersectingRoad = First(intersectingRoads);&lt;/P&gt;&lt;P&gt;// Snap the point to the closest place along the line and find the segment it intersects and the distance along the line&lt;BR /&gt;var data = closestPointInfo(geom, Geometry(intersectingRoad));&lt;BR /&gt;var closest_point = createPoint(data["coordinates"], Geometry($feature)["spatialReference"])&lt;BR /&gt;var results = intersectDistanceAlong(closest_point, intersectingRoad)&lt;BR /&gt;var twoPtSegment = results[0];&lt;BR /&gt;var distanceAlongLine = results[1];&lt;/P&gt;&lt;P&gt;// Construct a new point geometry offset perpendicularly from the road&lt;BR /&gt;var xy = offsetPoint(twoPtSegment.paths[0][0], twoPtSegment.paths[0][1], geom, dist)&lt;BR /&gt;var newPoint = Point({ 'x' : xy[0], 'y' : xy[1], 'z' : 0, 'spatialReference' : geom.spatialReference });&lt;/P&gt;&lt;P&gt;// Get the new address number of the site address point based on the distance along the road and direction of the offset&lt;BR /&gt;var percentAlong = distanceAlongLine / Length(intersectingRoad);&lt;BR /&gt;var addrnum = getAddrNum(intersectingRoad, percentAlong, dir)&lt;/P&gt;&lt;P&gt;// Create an array of 1 or more new site address point as specified&lt;BR /&gt;// Store the related address point id, the calculated address number, the intersecting road name and set the status to Pending&lt;BR /&gt;var adds = []&lt;BR /&gt;for(var i=0; i&amp;lt;numpoints; i++) {&lt;BR /&gt;Push(adds, {&lt;BR /&gt;'attributes': Dictionary(addressptid_field, id, status_field, defaultstatus,&lt;BR /&gt;addrnum_field, addrnum, roadfullname_field, intersectingRoad[fullname_field],&lt;BR /&gt;addrcapturemeth_field, $feature[capturemeth_field]),&lt;BR /&gt;'geometry': newPoint&lt;BR /&gt;})&lt;BR /&gt;addrNum += increment;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Create new site address points -- where it stops working for sure&lt;BR /&gt;return {&lt;BR /&gt;'edit': [{&lt;BR /&gt;'className': "SiteAddressPointsMSD",&lt;BR /&gt;'adds': adds&lt;BR /&gt;}]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/74321"&gt;@ChrisFox&lt;/a&gt;&amp;nbsp;you had helped with our previous error on indexing, but this happened next. Any ideas of why this might be occurring and how to overcome it? Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 15:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1323916#M1089</guid>
      <dc:creator>masslc</dc:creator>
      <dc:date>2023-08-30T15:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: ADMS 2.0 Create Address Point - Z-value error</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1323922#M1090</link>
      <description>&lt;P&gt;It is a lot easier to read code if you post it as a code snippet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you post a screen shot like below for&amp;nbsp;SiteAddressPointsMSD&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MikeMillerGIS_1-1693408488455.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/79467i54C85DC2346079AF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MikeMillerGIS_1-1693408488455.png" alt="MikeMillerGIS_1-1693408488455.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 15:15:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1323922#M1090</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-08-30T15:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: ADMS 2.0 Create Address Point - Z-value error</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1324075#M1093</link>
      <description>&lt;P&gt;My guess would be that your SiteAddressPointsMSD feature class is not z-enabled. If you search for the line below in the code, you can see we are defaulting Z to 0:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var newPoint = Point({ 'x' : xy[0], 'y' : xy[1], 'z' : 0, 'spatialReference' : geom.spatialReference });&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You could change it to below if your feature class is not z enabled:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var newPoint = Point({ 'x' : xy[0], 'y' : xy[1], 'spatialReference' : geom.spatialReference });&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 19:59:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1324075#M1093</guid>
      <dc:creator>ChrisFox</dc:creator>
      <dc:date>2023-08-30T19:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: ADMS 2.0 Create Address Point - Z-value error</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1325930#M1100</link>
      <description>&lt;P&gt;Thanks, Chris, that worked. I was looking at the address points MSD which are Z-enabled, but you're right, the site address points MSD were not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 15:05:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/adms-2-0-create-address-point-z-value-error/m-p/1325930#M1100</guid>
      <dc:creator>masslc</dc:creator>
      <dc:date>2023-09-06T15:05:46Z</dc:date>
    </item>
  </channel>
</rss>

