POST
|
Hi, so far I didn't find any real Official JSON format (if that exist). I've found the ESRI JSON input format expected by a geoprocessing service for ArcGIS 10.0. http://help.arcgis.com/EN/arcgisserver/10.0/apis/rest/index.html So I know exactly what the geoprocessing service expects. I've also seen how a featureSet should be sent to a geoprocessing service through the submitJob function of the esri.tasks.Geoprocessor. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/geoprocessor.htm My problem is to figure out, where does that geoprocessor find its toJson function for a featureSet. ESRI says that the format expected should be some like this : {
"geometryType" : "esriGeometryPoint",
"spatialReference" : {"wkid" : 4326},
"features" : [
{
"geometry" : {"x" : -104.44, "y" : 34.83},
"attributes" : {"Id" : 43, "Name" : "Feature 1"}
},
{
"geometry" : {"x" : -100.65, "y" : 33.69},
"attributes" : {"Id" : 67, "Name" : "Feature 2"}
}
]
} But then, the geoprocessor object create the JSON from my featureSet like this: {
"fields":[],
"geometryType":"esriGeometryPoint",
"features":[
{
"geometry":{"x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
"attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true}
}
],
"sr":{"wkid":3400}
} Althought the JSON.stringify() method give me this : {
"features":[
{
"geometry":{"type":"point","x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
"symbol":null,
"attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true},
"infoTemplate":{"title":"Main Camp","content":"Latitude: 56.123456<br>Longitude: -112.12345678"}
}
],
"geometryType":"esriGeometryPoint",
"spatialReference":{"wkid":3400}
} I've tried to call the service from the rest end point with both JSON featureSet and I found out why the JSON object created by the geoprocessor does not work. It simply that, as you can notice, the spatial reference from the geoprocessor is noted as "sr":{"wkid":3400} while form the stringify method it is noted as "spatialReference":{"wkid":3400} which is the expected format. I'm wondering if this is normal and there is just something I'm missing, or is it simply a bug from esri.tasks.geoprocessor. That is why I'd like to know what does the esri.tasks.geoprocessor uses for the purpose of converting FeatureSet to JSON and how can I work around that problem. If anyone has encountered that problem or has a hint on how to solve this, it'd be appreciated. Thank you
... View more
05-23-2012
01:24 PM
|
0
|
0
|
2413
|
POST
|
Hi everyone, I would like to know where can I find the real official JSON formats with versions. Is there a real standard somewhere? Does ESRI uses that standard? Where can I find the official ESRI JSON formats? What standard does JSON.stringify() uses? I have found it very difficult to find reliable information on this. BTW: My problem is that I'm trying to call a geoprocessing service on ArcGIS 10.0, but the translation from my javascript FeatureSet to JSON is not proper to what the greopressing service expect. In the request, the input has a different format and has empty values. Service I'm trying to call : http://oxpgisws01d.env.gov.ab.ca/ArcGIS/rest/services/IWCP/IWCP/GPServer/PointsLocationValidation Thanks
... View more
04-30-2012
02:02 PM
|
1
|
5
|
10379
|
POST
|
Actually I found out what was the problem. (very stupid indeed) It is simply that I was using coordinates that fell outside of the projection limitations. Because at first, I was using the esri.geometry.geographicToWebMercator() function and the 0 longitude with that projection is completely different than the 0 longitude of my projection. So when I projected to the projection I wanted, I had a Nan as x,y outputs. Recommandation : Verify if your data coordinates are logical. Very simple, but can be forgotten.
... View more
03-28-2012
08:30 AM
|
0
|
0
|
552
|
POST
|
I found out that in js 2.8 with ArcGIS 10.0 installed, we supposed to be able to create an esri.SpatialReference with a wkt as an entry as shown in the link below. I followed the exemple showed here, but even the exemple did not work. http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm Any idea?
... View more
03-27-2012
12:37 PM
|
0
|
0
|
552
|
POST
|
Hi, I'm using the project function of esri.tasks.GeometryService and I have a problem with my particular projection. I've tried with different projections and some in the wkid over 32000 works fine but it seems that there are a few projections which I cannot project too (including wkid:3400 the one I need it too project). My input wkid is 4269 (GCS_North_American_1983) and output wkid is 3400 (NAD_1983_10TM_AEP_Forest). I've read on the forums here that the project service cannot change the reference system, but here I'm on the same NAD83 ref. sys. Anyone has an idea on how I could resolve this problem? <code> //features is the input, an array of points var gsvc = new esri.tasks.GeometryService("http://oxpgisws01d.env.gov.ab.ca/ArcGIS/rest/services/Geometry/GeometryServer"); mapSR = new esri.SpatialReference({ wkid: 3400}); gsvc.project(features, mapSR, function(projectedPoints) { features = projectedPoints; } </code> Thanks
... View more
03-27-2012
07:11 AM
|
0
|
3
|
2667
|
POST
|
I found out what was missing. the tag : dojo.require("esri.layers.FeatureLayer"); at the beginning of the script. Seems like the dojo.require is kinda of an import library.
... View more
02-27-2012
09:10 AM
|
0
|
0
|
170
|
POST
|
Hi, I'm trying to add a FeatureLayer to my map, but I can't seem to be able to create a FeatureLayer. I tried with the featureCollection and the url (that was valid) but neither option worked. I added Firebug and JavaScript Debuger, but I don't really know how to use them yet. So I don't know how to get an error message to help me. Any suggestions? <code> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title></title> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css" /> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.css" /> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dijit/themes/claro/claro.css" /> <style type="text/css"> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #map{ margin: 0; padding: 0; } </style> <script type="text/javascript">var dojoConfig = { parseOnLoad: true };</script> <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5" type="text/javascript"></script> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); var map; function CreateFeatureLayer(graphics) { //document.write("CreateFeatureLayer" + "<br />"); var featrSet = new esri.tasks.FeatureSet(); featrSet.features = graphics; featrSet.geometryType = "esriGeometryPoint"; var layerDef = { "geometryType": "esriGeometryPoint", "fields": [{ "name": "SITES", "type": "esriFieldTypeInteger", "alias": "Sites" }] } //document.write("CreateFeatureLayer mid1" + "<br />"); var featureCollection = {"layerDefinition": layerDef, "featureSet": featrSet}; //document.write("CreateFeatureLayer mid2" + "<br />"); var featureLayer = new esri.layers.FeatureLayer(featureCollection, {mode: esri.layers.FeatureLayer.MODE_SNAPSHOT}); //document.write("CreateFeatureLayer fin" + "<br />"); return featureLayer; } function getSymbol(type) { var url = "" switch (type) { case "Permanent": url = "images/circle_blue.svg"; break; case "Equipment": url = "images/triangle_blue.svg"; break; case "Temporary": url = "images/star_blue.svg"; break; case "Sprinkler": url = "images/square_blue.svg"; break; } return new esri.symbol.PictureMarkerSymbol(url, 20, 20); } function GetGraphicArray(theString) { //document.write("GetGraphicArray" + "<br />"); var firstsplit = theString.split(';'); var singleElement var secondSplit var infoTemplate var pt var graphic var graphics = new Array(); while(firstsplit.length > 0) { singleElement = firstsplit.shift(); secondSplit = singleElement.split(","); symbol = getSymbol(secondSplit[1]); infoTemplate = new esri.InfoTemplate(secondSplit[1], secondSplit[2]); pt = new esri.geometry.Point(secondSplit[3], secondSplit[4], 3400); merc_pt = esri.geometry.geographicToWebMercator(pt); graphic = new esri.Graphic(merc_pt, symbol, '', infoTemplate); graphics.push(graphic); } return graphics; } function DisplayElements(theString) { //document.write("DisplayElements" + "<br />"); var graphics = GetGraphicArray(theString); var featureLayer = CreateFeatureLayer(graphics); //map.addLayer(featureLayer); map.graphics.add(graphics[0]); map.graphics.add(graphics[1]); map.graphics.add(graphics[2]); map.graphics.add(graphics[3]); map.graphics.add(graphics[4]); map.graphics.add(graphics[5]); map.graphics.add(graphics[6]); } function init() { //document.write("init" + "<br />"); var initExtent = new esri.geometry.Extent({"xmin":-562799.140878082,"ymin":5331608.39701711,"xmax":1547257.08731259,"ymax":6786507.98048048,"spatialReference":{"wkid":3400}}); map = new esri.Map("map",{extent:initExtent}); //Add the basemap layer var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://oxpgisws01d.env.gov.ab.ca/ArcGIS/rest/services/Cached_Sample/MapServer", {"opacity":1}); map.addLayer(basemap); dojo.connect(map, 'onLoad', function() { dojo.connect(dijit.byId('map'), 'resize', map, map.resize); theString = "Main Camp,Permanent,This is the main scout's camp.,6,50,Valid;" + "Summer camp,Temporary,This is the summer scout's camp.,5.9,49.8,Valid;" + "Winter camp,Temporary,This is the winter scout's camp.,6,49.8,Valid;" + "Bulldozer 1,Equipment,This is a Bulldozer.,4,46,Valid;" + "Bulldozer 2,Equipment,This is a Bulldozer.,4,47,Valid;" + "Sprinkler 33,Sprinkler,This is a sprinkler,5,49,Valid;" + "Sprinkler 34,Sprinkler,This is a sprinkler,5,49.5,Valid"; DisplayElements(theString); }); } dojo.ready(init); </script> </head> <body class="tundra"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width: 100%; height: 100%; margin: 0;"> <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> </div> </div> </body> </html> </code>
... View more
02-27-2012
08:05 AM
|
0
|
2
|
556
|
Title | Kudos | Posted |
---|---|---|
1 | 04-30-2012 02:02 PM |
Online Status |
Offline
|
Date Last Visited |
05-17-2021
08:47 AM
|