Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Using Esri SDK for Unity

Discussion in 'Scripting' started by Deivydas4, Nov 15, 2023.

  1. Deivydas4

    Deivydas4

    Joined:
    Oct 28, 2021
    Posts:
    22
    Hello!

    Maybe someone is using or was using and ArcGIS Maps SDK for Unity and knows how to do "Spatial filtering"
    This is what is written in documentation https://ibb.co/fvfbv3y
    But I don't quite understand, tried some methods but it didn't worked. The thing I want to do is, I downloaded a city scene layer an uploaded it into unity and I want to delete one part of city using spatial filtering.
    This is what I tried
    Code (CSharp):
    1.     void CreatePolygons()
    2.     {
    3.         ArcGISPolygonBuilder pb = new ArcGISPolygonBuilder(ArcGISSpatialReference.WGS84());
    4.         ArcGISCollection<ArcGISPolygon> polygons = new ArcGISCollection<ArcGISPolygon>();
    5.  
    6.         pb.AddPoint(21.129886, 55.663686);
    7.         pb.AddPoint(21.169546, 55.673128);
    8.         pb.AddPoint(21.189802, 55.636810);
    9.         pb.AddPoint(21.132897, 55.631965);
    10.  
    11.         ArcGISPolygon polygon = (ArcGISPolygon)pb.ToGeometry();
    12.  
    13.         ArcGISSpatialFeatureFilter filter = new ArcGISSpatialFeatureFilter(polygons, ArcGISSpatialFeatureFilterSpatialRelationship.Disjoint);
    14.  
    15.         ArcGIS3DObjectSceneLayer layer = GameObject.Find("ArcGISMap").GetComponent<ArcGIS3DObjectSceneLayer>();
    16.         layer.FeatureFilter = filter;
    17.     }
    If someone has some ideas how to achieve this, it would be pleasure to hear that.

    Thank you!
     
    Last edited: Nov 16, 2023
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,329
    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - what actually happened, log output, variable values, and especially any errors you see
    - links to documentation you used to cross-check your work (CRITICAL!!!)

    The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven't put effort into finding the documentation, why should we bother putting effort into replying?



    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/

    - Do not TALK about code without posting it.
    - Do NOT post unformatted code.
    - Do NOT retype code. Use copy/paste properly using code tags.
    - Do NOT post screenshots of code.
    - Do NOT post photographs of code.
    - Do NOT attach entire scripts to your post.
    - ONLY post the relevant code, and then refer to it in your discussion.
     
  3. Deivydas4

    Deivydas4

    Joined:
    Oct 28, 2021
    Posts:
    22
    Code (CSharp):
    1.     void CreateSpatialFilter(ArcGIS3DObjectSceneLayer layer)
    2.     {
    3.         ArcGISPolygonBuilder pb = new ArcGISPolygonBuilder(ArcGISSpatialReference.WGS84());
    4.         ArcGISPoint point1 = new ArcGISPoint(21.131577142997067, 55.637023413731804, ArcGISSpatialReference.WGS84());
    5.         ArcGISPoint point2 = new ArcGISPoint(21.133894571715896, 55.67290525808961, ArcGISSpatialReference.WGS84());
    6.         ArcGISPoint point3 = new ArcGISPoint(21.15449393771106, 55.67580923146909, ArcGISSpatialReference.WGS84());
    7.         ArcGISPoint point4 = new ArcGISPoint(21.180672298663247, 55.64579111054236, ArcGISSpatialReference.WGS84());
    8.  
    9.         pb.AddPoint(point1);
    10.         pb.AddPoint(point2);
    11.         pb.AddPoint(point3);
    12.         pb.AddPoint(point4);
    13.  
    14.         ArcGISPolygon polygon = (ArcGISPolygon)pb.ToGeometry();
    15.         ArcGISCollection<ArcGISPolygon> polygons = new ArcGISCollection<ArcGISPolygon>();
    16.         polygons.Add(polygon);
    17.  
    18.         ArcGISSpatialFeatureFilter filter = new ArcGISSpatialFeatureFilter(polygons, ArcGISSpatialFeatureFilterSpatialRelationship.Disjoint);
    19.         layer.FeatureFilter = filter;
    20.     }
    Found the solution.