Select to view content in your preferred language

Geometry to JSON Flex 2.4

959
5
08-12-2011 04:48 AM
FranciscoBereciartu
Occasional Contributor
Hi,

I have a Geometry object result from the Geometry service of ArcGIS Server 10, and I want so send over that Geometry to do another process using a SOE in C# but the goetry is huge my questions are:
1.- Geometry this huge can be sent over using POST or can't be done? if the 1st was true, there is a method in Flex API to converte the geometry to JSON or it has to be manually?


Thanks in advance
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Francisco,

   Sure you can. To JSON encode the data there is a class for that.

import com.esri.ags.utils.JSON;
JSON.encode(your geometries array);
0 Kudos
FranciscoBereciartu
Occasional Contributor
Francisco,

   Sure you can. To JSON encode the data there is a class for that.

import com.esri.ags.utils.JSON;
JSON.encode(your geometries array);


Hi Robert,

Thanks for you answer. I would like to know which parameters of the geometry object I should pass on in the JSON besides the points array. Thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Francisco,

   That is up to you as the developer and what your SOE is looking for. Not sure I can help you more.
0 Kudos
BjornSvensson
Esri Regular Contributor
result from the Geometry service ... and I want so send over that Geometry to do another process using a SOE ... but the goetry is huge


Not sure if if makes sense in your case, but one feature that is often overlooked in general is the ability to send a URL that will return geometries instead of the actual geometries. Whether a GP or SOE, depending on your specific use case, you might want to just send a URL to something like (instead of retrieving, parsing, returning those three polygons):

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/buffer?geometries...{%22geometries%22%3A%5B{%22x%22%3A1469510.0355645495%2C%22y%22%3A7499622.6821904825}%5D%2C%22geometryType%22%3A%22esriGeometryPoint%22}&inSR=102100&outSR=102100&bufferSR=4326&distances=10%2C50%2C100&unit=9036&unionResults=false&f=json

Again, depending on your specific use case, this might or might not be a good idea 🙂
0 Kudos
FranciscoBereciartu
Occasional Contributor
Not sure if if makes sense in your case, but one feature that is often overlooked in general is the ability to send a URL that will return geometries instead of the actual geometries. Whether a GP or SOE, depending on your specific use case, you might want to just send a URL to something like (instead of retrieving, parsing, returning those three polygons):

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/buffer?geometries={%22geometries%22%3A%5B{%22x%22%3A1469510.0355645495%2C%22y%22%3A7499622.6821904825}%5D%2C%22geometryType%22%3A%22esriGeometryPoint%22}&inSR=102100&outSR=102100&bufferSR=4326&distances=10%2C50%2C100&unit=9036&unionResults=false&f=json

Again, depending on your specific use case, this might or might not be a good idea 🙂


Thank you for yours answers.

bjorn,

I'm using JSON.encode to encode my Geometry object to pass it to a SOE, but when I encode the geometry the result is liek this {"rings":[[[341839.7316,7715308.5897],...., "spatialReference":{"wkid":31984}} and when I try to do a jsonObject.TryGetJsonObject(...) it gives me an error like it can't be found but all the string arrives because I do TryGetString and all the string arrives, I'm trying to retrevie that object an create an instance of that geometry in C#... am I missing something?? before I create the JSON, the geometry object has more attributes ... the flex builder documentation says in the encode method (Encodes a Flex object into a JSON string. Note that for a graphic, convertToJSON will convert attributes and geometry, but not the symbol) but I don't understand what does this mean (I'm newbie in arcGiS world)

Thanks in advance
0 Kudos