Get Imageservicelayer raster values in ArcGIS Runtime SDK for iOS

Source: Internet
Author: User


This article original, reprint please indicate original address http://blog.csdn.net/dongyu1009/article/details/37697389


use Agsimageserviceidentifytask to get the raster values in the Arcgisimageservicelayer layer. This involves three more important classes: Agsimageserviceidentifyparameters, Agsimageserviceidentifytask and Agsimageserviceidentifyresult, there is also a delegate proxy class. The following one by one brief introduction:


Agsimageserviceidentifyparameters

Agsimageserviceidentifyparameters is used to set the Identify parameter, you can use the class method Imageserviceidentifyparameters constructs, namely

[Agsimageserviceidentifyparameters Agsimageserviceidentifyparameters];

Agsimageserviceidentifyparameters includes the following properties

---Geometry is used to specify the location of the query raster, often a agspoint, or you can use Agspolygon to query the raster values of an area.

---mosaicrule is a mosaic rule, which defaults to Agsmosaicmethodcenter.

---Pixelsizex and Pixelsizey are used to set the cell size, which defaults to the cell size of the query raster layer. All mosaic datasets within the cell size range will be queried.


Agsimageserviceidentifytask

When instantiating, you need to set the URL of the query and set credential if you need to verify it.

Nothing else to introduce, before the query has to set up a proxy for the query, when queried-(nsoperation*) Identifywithparameters: (Agsimageserviceidentifyparameters *) Identifyparams method.


Agsimageserviceidentifyresult


Catelogitems is the returned raster catalog (I don't know how to translate it, a raster catelog is a collection of raster DataSet raster datasets).

catalogitemvisibilities As the name implies, is the raster catalog visible

location is the identify of the query.

name is the identify query's property names

ObjectId doesn't explain, it's an ID.

Properties is a collection of attributes

value is the cell value of the name corresponding attribute


Agsimageserviceidentifydelegate

Proxy is used to obtain the results of the query, you must implement the following two methods, the first is the identify query failed when the call, the second is the identify query successfully called, will get a Agsimageserviceidentifyresult object.

(void)-ImageServiceIdentifyTask:operation:didFailToIdentifyWithError:

(void)-ImageServiceIdentifyTask:operation:didIdentifyWithResult:


Here are the specific ways to use it.

1, set the agent for Viewcontroller, and implement the two methods of query completion:

In the ViewController.h

#import <UIKit/UIKit.h>
#define Image_service "Http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/World/MODIS/ImageServer" </p > @interface viewcontroller:uiviewcontroller <AGSImageServiceIdentifyDelegate> @property (Strong, Nonatomic ) Agsimageserviceidentifytask *task; @end

in the VIEWCONTROLLER.M

-(void) Imageserviceidentifytask: (agsimageserviceidentifytask*) Identifytask operation: (nsoperation*) op Dididentifywithresult: (Agsimageserviceidentifyresult *) result{    NSLog (@ "Properties:%@", result.properties);    NSLog (@ "Value:%@", result.value);    NSLog (@ "Name:%@", result.name);    NSLog (@ "Catalogitems count:%d", [[Result.catalogitems features] count]);} -(void) Imageserviceidentifytask: (agsimageserviceidentifytask*) Identifytask operation: (nsoperation*) op Didfailtoidentifywitherror: (Nserror *) error{    NSLog (@ "Fault");}


2. Set agsimageserviceidentifyTask:

    Self.task = [[Agsimageserviceidentifytask alloc] Initwithurl:[nsurl Urlwithstring:image_service]];    Self.task.delegate = self;


3. Set agsimageserviceidentifyparameters:

        Agsimageserviceidentifyparameters *param = [Agsimageserviceidentifyparameters imageserviceidentifyparameters];        Param.geometry = [Agspoint pointwithx:116.425541 y:39.969147 spatialreference:[agsspatialreference SPATIALREFERENCEWITHWKID:4326]];        [Self.task Identifywithparameters:param];


The complete code is as follows:

In ViewController.h

  viewcontroller.h//  wang////  Created by Dongyu on 14-7-10.//  Copyright (c) 2014 Org.reach. All rights reserved.//#import <UIKit/UIKit.h> @interface Viewcontroller:uiviewcontroller < Agsimageserviceidentifydelegate> @property (Strong, nonatomic) Agsimageserviceidentifytask *task; @end

In the VIEWCONTROLLER.M

viewcontroller.m//wang////Created by Dongyu on 14-7-10.//Copyright (c) 2014 Org.reach. All rights reserved.//#import "ViewController.h" #define Image_service @ "http://sampleserver3.arcgisonline.com/ Arcgis/rest/services/world/modis/imageserver "@interface Viewcontroller () @end @implementation viewcontroller-(void        ) viewdidload{[Super Viewdidload];    Self.task = [[Agsimageserviceidentifytask alloc] Initwithurl:[nsurl Urlwithstring:image_service]];        Self.task.delegate = self;        Agsimageserviceidentifyparameters *param = [Agsimageserviceidentifyparameters imageserviceidentifyparameters]; Param.geometry = [Agspoint pointwithx:116.425541 y:39.969147 spatialreference:[agsspatialreference        SPATIALREFERENCEWITHWKID:4326]];    [Self.task Identifywithparameters:param];    }-(void) didreceivememorywarning{[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} #pragma mark-delegate-(void) Imageserviceidentifytask: (Agsimageserviceidentifytask*) Identifytask operation: (nsoperation*) op dididentifywithresult: (Agsimageserviceidentifyresult *)    result{NSLog (@ "Properties:%@", result.properties);    NSLog (@ "Value:%@", result.value);    NSLog (@ "Name:%@", result.name); NSLog (@ "Catalogitems count:%d", [[Result.catalogitems features] count]);} -(void) Imageserviceidentifytask: (agsimageserviceidentifytask*) Identifytask operation: (nsoperation*) op Didfailtoidentifywitherror: (Nserror *) error{NSLog (@ "Fault");} @end



Demo's:

http://download.csdn.net/detail/dongyu1009/7623695


The novice sends the blog, has the bad place, hoped everybody criticizes correct.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.