<?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: ArcGIS error &amp;quot;target_extent has zero for width or height&amp;quot; in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219051#M7468</link>
    <description>&lt;P&gt;I see. It happens when the points are sharing the same latitude or longitude. I can see why it might happen - if all the points are on a same line parallel to x or y axis, then the bounding box (extent) of the geometry would be ill-formed, not being a rectangle but a line.&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I'll query our team on their thoughts, but I personally think the behavior is expected,&lt;/STRIKE&gt; as indicated in the error message:&amp;nbsp;target_extent has zero for width or height. A point or a x/y-parallel polyline doesn't have a valid rectangle extent.&lt;/P&gt;&lt;P&gt;&lt;FONT face="terminal,monaco"&gt;Edit: team think it is a bug for not working on horizontal and vertical lines, will be fixed in the future.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the meantime, here are a few alternatives you may consider.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;Setting viewpoint with center and scale.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;You can always set a viewpoint to the center of your geometry and apply a scale, such as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;mapView.setViewpointCenter(polygon.extent.center, scale: 1e4)&lt;/LI-CODE&gt;&lt;P&gt;this is preferred because you can control the exact location and scale where you want to look at.&amp;nbsp;&lt;SPAN&gt;Consider a point could represent a street address, or the centroid of a country - how much you zoom depends on what the point represents&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Setting viewpoint with a buffered geometry.&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;If you buffer the center point of a geometry to a circle, it would always have a valid extent. Please notice, the planar buffer works the best with an &lt;A href="https://en.wikipedia.org/wiki/Equal-area_map" target="_self"&gt;equal-area projection&lt;/A&gt;&amp;nbsp;map, and makes more sense to use with Web Mercator than WGS 84. We do have a geodetic buffer but that might be an overkill here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;// Note the distance is in the unit of the geometry's spatial reference, so with lat-lon it means 1 degree.
mapView.setViewpointGeometry(AGSGeometryEngine.bufferGeometry(polygon.extent.center, byDistance: 1)!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 23:46:44 GMT</pubDate>
    <dc:creator>Ting</dc:creator>
    <dc:date>2022-10-05T23:46:44Z</dc:date>
    <item>
      <title>ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218505#M7460</link>
      <description>&lt;P&gt;I tried to set view point for ArcGIS map and encountered an error exception:&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error:&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;Error Domain=com.esri.arcgis.runtime.error Code=2 "Invalid argument." UserInfo={NSLocalizedFailureReason=target_extent has zero for width or height., NSLocalizedDescription=Invalid argument., Additional Message=target_extent has zero for width or height.}&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;The code to set the view point is attached bellow, and I recognized that the error just happens with some AGSPoint.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 03:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218505#M7460</guid>
      <dc:creator>trieunguyenaxon</dc:creator>
      <dc:date>2022-10-04T03:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218698#M7462</link>
      <description>&lt;P&gt;Please see the attached project. I cannot reproduce the error.&lt;/P&gt;&lt;P&gt;Can you give another try or provide a minimal reproducible example?&lt;/P&gt;&lt;P&gt;One thing to consider, although it works, a "polygon" with only 2 vertices is basically a polyline.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 16:42:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218698#M7462</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2022-10-04T16:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218870#M7465</link>
      <description>&lt;P&gt;I send you the reproduce project. I already updated the locations which caused this issue.&lt;BR /&gt;Could you help me take a look? Thank you so much&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 00:18:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1218870#M7465</guid>
      <dc:creator>trieunguyenaxon</dc:creator>
      <dc:date>2022-10-05T00:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219051#M7468</link>
      <description>&lt;P&gt;I see. It happens when the points are sharing the same latitude or longitude. I can see why it might happen - if all the points are on a same line parallel to x or y axis, then the bounding box (extent) of the geometry would be ill-formed, not being a rectangle but a line.&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I'll query our team on their thoughts, but I personally think the behavior is expected,&lt;/STRIKE&gt; as indicated in the error message:&amp;nbsp;target_extent has zero for width or height. A point or a x/y-parallel polyline doesn't have a valid rectangle extent.&lt;/P&gt;&lt;P&gt;&lt;FONT face="terminal,monaco"&gt;Edit: team think it is a bug for not working on horizontal and vertical lines, will be fixed in the future.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the meantime, here are a few alternatives you may consider.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;Setting viewpoint with center and scale.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;You can always set a viewpoint to the center of your geometry and apply a scale, such as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;mapView.setViewpointCenter(polygon.extent.center, scale: 1e4)&lt;/LI-CODE&gt;&lt;P&gt;this is preferred because you can control the exact location and scale where you want to look at.&amp;nbsp;&lt;SPAN&gt;Consider a point could represent a street address, or the centroid of a country - how much you zoom depends on what the point represents&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Setting viewpoint with a buffered geometry.&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;If you buffer the center point of a geometry to a circle, it would always have a valid extent. Please notice, the planar buffer works the best with an &lt;A href="https://en.wikipedia.org/wiki/Equal-area_map" target="_self"&gt;equal-area projection&lt;/A&gt;&amp;nbsp;map, and makes more sense to use with Web Mercator than WGS 84. We do have a geodetic buffer but that might be an overkill here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;// Note the distance is in the unit of the geometry's spatial reference, so with lat-lon it means 1 degree.
mapView.setViewpointGeometry(AGSGeometryEngine.bufferGeometry(polygon.extent.center, byDistance: 1)!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 23:46:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219051#M7468</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2022-10-05T23:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219217#M7470</link>
      <description>&lt;P&gt;Grate! This solution works for me. But with the first solution, could you share with me how to calculate the scale factor. Because the scale is depended on the points which I want to show on the map. I want to show all of the points to the map, so the scale should be suitable to show all points.&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;mapView.setViewpointCenter(polygon.extent.center, scale: 1e4)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 03:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219217#M7470</guid>
      <dc:creator>trieunguyenaxon</dc:creator>
      <dc:date>2022-10-06T03:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219529#M7474</link>
      <description>&lt;P&gt;Well, a possible workaround might look like this&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let extent: AGSEnvelope
if min(polygon.extent.width, polygon.extent.height) == .zero {
    let length = max(polygon.extent.width, polygon.extent.height)
    extent = AGSEnvelope(center: polygon.extent.center, width: length, height: length)
} else {
    extent = polygon.extent
}
mapView.setViewpointGeometry(extent)&lt;/LI-CODE&gt;&lt;P&gt;When the extent of the polygon/polyline has zero width or height, add a condition to adjust its extent to a square, so that it can be correctly converted to a valid viewpoint target extent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't mind losing the original tightly-bound behavior, simply create a square extent for all geometries, regardless of whether it has a zero dimension or not.&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let length = max(polygon.extent.width, polygon.extent.height)
let extent = AGSEnvelope(center: polygon.extent.center, width: length, height: length)
mapView.setViewpointGeometry(extent)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Although this is just a temporary fix and doesn't work perfectly. Hopefully the bug will be addressed in the upcoming versions of Runtime. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 18:43:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219529#M7474</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2022-10-06T18:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS error "target_extent has zero for width or height"</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219713#M7475</link>
      <description>&lt;P&gt;Thank you for your solution. It work perfectly&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 04:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/arcgis-error-quot-target-extent-has-zero-for-width/m-p/1219713#M7475</guid>
      <dc:creator>trieunguyenaxon</dc:creator>
      <dc:date>2022-10-07T04:58:03Z</dc:date>
    </item>
  </channel>
</rss>

