|
POST
|
Than Aung 2nd Loaded Last question.... Where can I read up more on this solution? Is there decent documentation and some hello world examples? Can I also work with map like the arcgis JavaScript api 4.14? Query, return results write to graphics layer etc? I am trying to deal with the " " in my string as such... string inputParam = "{\"employees\":[{\"address\":\"1520 Split Oak Ln, Henrico, Virginia, 23229\",\"distance\":\"10\",\"id\":\"9a35172e071f4a33b191172a9b4b02ae\"}]}"; Should I have to use a ? like this paramString.Append($"?request="+ inputParam); I can go into the RestEndpoint and input as such and it works great.....BUT for some reason the way I am passing the parameter its not working.... IT works from the restendpoint fine but does not work from C# This is my total code protected void btnPassParameters_Click(object sender, EventArgs e)
{
string gpUrl = "https://xxxa.gov/arcgis/rest/services/Test/Counties/GPServer/create";
string requestUrl = gpUrl + "/execute";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(gpUrl));
request.KeepAlive = true;
request.Method = "POST";
request.AllowAutoRedirect = true;
request.CookieContainer = new System.Net.CookieContainer();
request.ContentType = "application/json";
StringBuilder paramString = new StringBuilder();
string inputParam = "{\"employees\":[{\"address\":\"1520 Split Oak Ln, Henrico, Virginia, 23229\",\"distance\":\"10\",\"id\":\"9a35172e071f4a33b191172a9b4b02ae\"}]}";
paramString.Append($"?request="+ inputParam);
//paramString.Append($"request={requestParamString}");
paramString.Append($"&f=json");
byte[] data = Encoding.ASCII.GetBytes(paramString.ToString());
request.ContentLength = data.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string responseStr = getStringFromWebResponse(response);
Response.Write(responseStr);
}
public string getStringFromWebResponse(WebResponse response)
{
// Get the stream containing content returned by the server.
Stream responseDataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(responseDataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Clean up the streams.
reader.Close();
responseDataStream.Close();
response.Close();
return responseFromServer;
}
... View more
04-16-2020
09:39 AM
|
0
|
2
|
3826
|
|
POST
|
Having an issue....trying to pass this string {"employees":[{"address":"2125 Baldwin Avenue,Crofton,MD, 21114","distance":"50","id":"4e0e9919-b88f-4073-a621-1279de2a3579"}] } it could be this as well... {"employees":[{"address":"2125 Baldwin Avenue,Crofton,MD, 21114","distance":"50","id":"4e0e9919-b88f-4073-a621-1279de2a3579"}, {"address":"1245 Baldwin Avenue,Crofton,MD, 21114","distance":"50","id":"4e0e9919-b88f-4073-a621-1279de2a3579"}] } If I put " " around my parameter it does not like it.... string requestParamString = " {"employees":[{"address":"2125 Baldwin Avenue, #40,Crofton,MD, 21114","distance":"50","id":"4e0e9919-b88f-4073-a621-1279de2a3579"}] } "
... View more
04-16-2020
07:13 AM
|
0
|
0
|
3826
|
|
POST
|
this is what I am trying to do now....just saw that loop Although this still returns the features that are outside the area of interest....does not seem to be using this if (testPoly.contains(graphic.geometry.centroid)) { Think it might be this. Where I am calling the "results" again var features3 = results.features.map(function (graphic) { function displayResults2(results) {
var testPoly = resultsLayer2.graphics.items[0].geometry;
results.features.map(function (graphic) {
//queryCountiesthatIntersect.then(function (results) {
if (testPoly.contains(graphic.geometry.centroid)) {
var features3 = results.features.map(function (graphic) {
graphic.symbol = {
type: "simple-fill",
style: "solid",
color: [240, 248, 255, 0.9],
size: "10px", // pixels
outline: {
// autocasts as new SimpleLineSymbol()
color: [191, 42, 18, 0.9],
width: 1 // points
}
};
return graphic;
});
var numCounties = features3.length;
alert(numCounties);
resultsLayer3.addMany(features3);
}
});
... View more
04-14-2020
01:28 PM
|
0
|
1
|
4357
|
|
POST
|
Having a hard time following this.. I have: CountyLayer var countyLayerWebMercator = new FeatureLayer({ this is the full county layer with hundreds of polygons resultsLayer2 this is a graphic layer that houses the large polygon for the query. this is the poly that I want to identify all the counties from the County Layer above resultsLayer3 this is the graphics layer where I want to write all the counties that are within the resultsLayer2 all the polygons that have their centroid in resultsLayer2 Am I missing something? // SNIP CODE ABOVE BUT HERE IS TEH CALL
queryCountiesthatIntersect().then(displayResults2).else(function (err) {
console.log(err);
});
}
function queryCountiesthatIntersect() {
var query = countyLayerWebMercator.createQuery();
query.geometry = resultsLayer2.graphics.items[0].geometry;
query.spatialRelationship = "intersects";
query.outFields = "*";
query.returnGeometry = true;
return countyLayerWebMercator.queryFeatures(query);
}
function displayResults2(results) {
queryCountiesthatIntersect.then(function (results) {
var testPoly = resultsLayer2.graphics.items[0].geometry;
results.features.map(function (graphic) {
if (testPoly.contains(graphic.geometry.centroid)) {
//Now you know if the centroid of the county is in your polygon
// and you can add that graphic to the map or whatever...
// alert(testPoly.length);
var features3 = graphic.features.map(function (graphic) {
graphic.symbol = {
type: "simple-fill",
style: "solid",
color: [240, 248, 255, 0.9],
size: "10px", // pixels
outline: {
// autocasts as new SimpleLineSymbol()
color: [191, 42, 18, 0.9],
width: 1 // points
}
};
return graphic;
});
var numCounties = features3.length;
alert(numCounties);
resultsLayer3.addMany(features3);
}
});
});
}
... View more
04-14-2020
01:01 PM
|
0
|
3
|
4357
|
|
POST
|
Can I grab the centroid for Query? Can I somehow tell the query to look at the centroids of each little county and use those centroids to find the ones that are "contained"???? var parcelCentroid = feature.geometry.getExtent().getCenter(); query Object Describes query operations that can be performed on features in the layer. Specification: maxRecordCount Number The maximum number of records that will be returned for a given query. supportsCentroid Boolean Indicates if the geometry centroid associated with each polygon feature can be returned. This operation is only supported in ArcGIS Online hosted feature services.
... View more
04-14-2020
10:44 AM
|
0
|
5
|
4357
|
|
POST
|
Should Return 11 Returns 3: Contains only gives me the ones that are completely contained within the Large Polygon....it does not give me the ones that are touching the boundary of the Large Polygon....those lines coincide and are not selected with Contains. Returns 19: If I use Overlaps I get this....I get the ones that lie outside selected because the lines coincide.
... View more
04-14-2020
09:04 AM
|
0
|
0
|
4357
|
|
POST
|
I am trying to query and return data from a spatial relationship. I have a county layer with many counties I have another Layer that has larger polygons that are made up of multiple counties. I want to use the larger polygon to select the smaller polygons that would be inside the geometry of the larger polygon. I have tried all the possible spatial relationships Possible Values: "intersects" | "contains" | "crosses" | "disjoint" | "envelope-intersects" | "index-intersects" | "overlaps" | "touches" | "within" | "relation" I think my issue is that the boundaries of the two Feature Layers coincide. Is there any other way to query these? Can I search by centroid of the polygon layer (create a centroid on the fly?) function queryCountiesthatIntersect() {
var query = countyLayer.createQuery();
query.geometry = resultsLayer.graphics.items[0].geometry;
query.spatialRelationship = "index-intersects";
query.outFields = "*";
query.returnGeometry = true;
return countyLayer.queryFeatures(query);
}
... View more
04-14-2020
07:52 AM
|
0
|
8
|
4450
|
|
POST
|
Thanks Robert Scheitlin, GISP for steering me in the right direction......much appreciated.
... View more
04-13-2020
02:36 PM
|
0
|
0
|
2213
|
|
POST
|
I got it with this: i was missing the "items" query.geometry = resultsLayer2.graphics.items[0].geometry; NOT query.geometry = resultsLayer2.graphics[0].geometry; I had to walk the console.log of the Graphics layer a bit more
... View more
04-13-2020
02:31 PM
|
0
|
0
|
6607
|
|
POST
|
Dosent give me anything...Add alert in there "In the Intersect" to make sure it was in the function Nothing in the Console Error wise... queryCountiesthatIntersect().then(displayResults2).else(function (err) { console.log(err); }); function queryCountiesthatIntersect() { console.log("In the Intersect"); console.log(resultsLayer2.graphics);
... View more
04-13-2020
01:33 PM
|
0
|
2
|
2213
|
|
POST
|
Looking at the console.log of the 1st Graphic Layer It appears to be in Web Mercator .... Spatial Reference: 102100 / 3857 Why the heck cant I use this to query another FC with geometry and write that to a graphic...
... View more
04-13-2020
01:00 PM
|
0
|
5
|
2213
|
|
POST
|
Both my datasets are Web Mercator Aux Sphere.... My map does not define a spatial reference....Could the Graphics be in a different projection and causing an issue?
... View more
04-13-2020
12:54 PM
|
0
|
0
|
2213
|
|
POST
|
04-13-2020
12:39 PM
|
0
|
0
|
2213
|
|
POST
|
I was using this ESRI Example: ArcGIS API for JavaScript Sandbox towards the bottom function displayResults(results) { resultsLayer.removeAll(); var features = results.features.map(function(graphic) { graphic.symbol = { type: "simple-marker", // autocasts as new SimpleMarkerSymbol() style: "diamond", size: 6.5, color: "darkorange" }; return graphic; }); var numQuakes = features.length; document.getElementById("results").innerHTML = numQuakes + " earthquakes found"; resultsLayer.addMany(features); }
... View more
04-13-2020
12:04 PM
|
0
|
9
|
4394
|
|
POST
|
This works fine and I get the 1st function to render the graphic layer properly resultsLayer2.addMany(features2); This does NOT work...the graphic layer in the first function does not draw. resultsLayer2.addMany([features2]); Still think there is an issue with this...when trying to use the geometry to find the counties that intersect the Graphic Layer written like this I get nothing query.geometry = resultsLayer2.graphics[0].geometry; written like this I get all 133 counties query.geometry = resultsLayer2;
... View more
04-13-2020
12:00 PM
|
0
|
0
|
4394
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|