Hoppa till huvudinnehållet

Best Practices - changing types

Kommentarer

2 kommentarer

  • Permanently deleted user

    Hi Jeff

    I think one place to broaden your knowledge without necessarily turning you into a programmer is understanding what some of these types are and when you actually are changing datatypes.

    Have a browse to http://resources.arcgis.com/en/help/silverlight-api/apiref/api_start.htm   (note that this is the Silverlight API and not necessarily applicable or equivalent to all other ESRI api's but it will be a good start)

    click on ESRI.ArcGIS.Client in the hierarchy tree on the left

    click on ESRI.ArcGIS.Client.Tasks

    find Featureset

    click on Featureset Members etc

    Anyway have any explore. You should find that a FeatureSet is a collection of Features and a Feature is a Graphic that may or may not have attributes or Geometry

    So sometimes it is not a conversion that you are doing but rather getting a property of an object or part of an object.

    Hope that helps

    Ralph

     

    0
  • Permanently deleted user

    FeatureSet to Geometry:

    • If you want the Geometry of the whole thing, use a Union Task, which takes a FeatureSet as input, and gives you a Geometry back.
    • If you want the Geometry of each feature, use ForEach loop to loop through each 'feature' in FeatureSet.Features (this is a foreach loop of type 'Graphic'). Then you can access the Geometry of each feature like this: feature.Geometry

    Graphics from a FeatureSet is as above, but you don't have to access any property of the feature, as the feature itself is a Graphic. 

    A FeatureSet has many different constructors. You can make a FeatureSet from a Geometry:

         myFeatureSet = new ESRI.ArcGIS.Client.Tasks.FeatureSet(myGeometry)

    or a list of Geometries:

         myGeometryList = new List(of Geometry) From { myGeometry1, myGeometry2, etc... }

         myFeatureSet = new ESRI.ArcGIS.Client.Tasks.FeatureSet(myGeometryList)

    You can also make a FeatureSet from a list of Graphics in the same manner.

    There's no constructor for a single Graphic, however nothing is stopping you from having a List with only one element. The following is totally valid:

         ?myFeatureSet = new ESRI.ArcGIS.Client.Tasks.FeatureSet( new List(of Graphic) From { myGraphic } )

    Just remember that FeatureSet.Features is a collection of Graphics, and each Graphic has a Geometry attribute (containing the spatial representation), and a Attributes dictionary (containing the table data).

    Hope this helps.

     

    0

Du måste logga in om du vill lämna en kommentar.