Skip to content

Commit de78593

Browse files
authored
Merge pull request #386 from jkey-esri/master
Merge Pro SDK Get Better Geoprocessing Tool Error Messages sample and Enterprise SDK FilterFeaturesByFieldSOI sample
2 parents 657db64 + 40389a4 commit de78593

18 files changed

+694
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// Copyright 2022 ESRI
2+
//
3+
// All rights reserved under the copyright laws of the United States
4+
// and applicable international laws, treaties, and conventions.
5+
//
6+
// You may freely redistribute and use this sample code, with or
7+
// without modification, provided you include the original copyright
8+
// notice and use restrictions.
9+
//
10+
// See the use restrictions at <your Enterprise SDK install location>/userestrictions.txt.
11+
//
12+
13+
using System;
14+
using System.Collections.Generic;
15+
using System.Linq;
16+
using System.Text;
17+
using System.Collections.Specialized;
18+
using System.Runtime.InteropServices;
19+
using ESRI.ArcGIS.esriSystem;
20+
using ESRI.ArcGIS.Server;
21+
using ESRI.ArcGIS.Geometry;
22+
using ESRI.ArcGIS.Geodatabase;
23+
using ESRI.ArcGIS.Carto;
24+
using ESRI.Server.SOESupport;
25+
using ESRI.Server.SOESupport.SOI;
26+
27+
//This is SOI template of Enterprise SDK
28+
29+
namespace FilterFeaturesByFieldSOI
30+
{
31+
[ComVisible(true)]
32+
[Guid("c9eaee50-c440-4b5a-b909-40e52e3f138c")]
33+
[ClassInterface(ClassInterfaceType.None)]
34+
[ServerObjectInterceptor("MapServer",
35+
Description = "",
36+
DisplayName = ".NET FilterFeaturesByField SOI",
37+
Properties = "",
38+
SupportsSharedInstances = true)]
39+
public class FilterFeaturesByFieldSOI : IServerObjectExtension, IRESTRequestHandler, IWebRequestHandler, IRequestHandler2
40+
{
41+
private string _soiName;
42+
private IServerObjectHelper _soHelper;
43+
private RestSOIHelper _restSOIHelper;
44+
45+
public FilterFeaturesByFieldSOI()
46+
{
47+
_soiName = this.GetType().Name;
48+
}
49+
50+
public void Init(IServerObjectHelper pSOH)
51+
{
52+
//System.Diagnostics.Debugger.Launch();
53+
54+
_soHelper = pSOH;
55+
_restSOIHelper = new RestSOIHelper(pSOH);
56+
}
57+
58+
public void Shutdown()
59+
{
60+
}
61+
62+
#region REST interceptors
63+
64+
public string GetSchema()
65+
{
66+
IRESTRequestHandler restRequestHandler = _restSOIHelper.FindRequestHandlerDelegate<IRESTRequestHandler>();
67+
if (restRequestHandler == null)
68+
return null;
69+
70+
return restRequestHandler.GetSchema();
71+
}
72+
73+
public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName,
74+
string operationInput, string outputFormat, string requestProperties, out string responseProperties)
75+
{
76+
responseProperties = null;
77+
78+
// Find the correct delegate to forward the request too
79+
IRESTRequestHandler restRequestHandler = _restSOIHelper.FindRequestHandlerDelegate<IRESTRequestHandler>();
80+
if (restRequestHandler == null)
81+
return null;
82+
83+
if (operationName == "export" || operationName == "identify" || operationName == "find")
84+
{
85+
var joOperationInput = new JsonObject(operationInput);
86+
var operationInputToJsonTest = joOperationInput.ToJson();
87+
88+
if (joOperationInput.Exists("layerDefs"))
89+
joOperationInput.Delete("layerDefs");
90+
91+
var joLayerDefsFilter = new JsonObject();
92+
// Filter the features by the POP attribute field.
93+
joLayerDefsFilter.AddString("0", "POP > 500000");
94+
joOperationInput.AddJsonObject("layerDefs", joLayerDefsFilter);
95+
96+
operationInput = joOperationInput.ToJson();
97+
}
98+
99+
return restRequestHandler.HandleRESTRequest(
100+
Capabilities, resourceName, operationName, operationInput,
101+
outputFormat, requestProperties, out responseProperties);
102+
}
103+
104+
private JsonObject CreateACircle()
105+
{
106+
string circleJs = "{\"spatialReference\":{\"wkid\":4269}, \"curveRings\": [[[-102, 41],{\"a\":[[-102, 41], [-104, 39], 0, 1]}]]}";
107+
IPolygon poly = ESRI.Server.SOESupport.Conversion.ToGeometry(circleJs, esriGeometryType.esriGeometryPolygon) as IPolygon;
108+
((IPolycurve)poly).Densify(0.1, 0.1); //Densifying as ToJsonObject() can't jsonify any curves
109+
return ESRI.Server.SOESupport.Conversion.ToJsonObject(poly, true);
110+
}
111+
112+
#endregion
113+
114+
#region SOAP interceptors
115+
public byte[] HandleBinaryRequest(ref byte[] request)
116+
{
117+
IRequestHandler requestHandler = _restSOIHelper.FindRequestHandlerDelegate<IRequestHandler>();
118+
if (requestHandler != null)
119+
{
120+
return requestHandler.HandleBinaryRequest(request);
121+
}
122+
123+
//Insert error response here.
124+
return null;
125+
}
126+
127+
public string HandleStringRequest(string Capabilities, string request)
128+
{
129+
IRequestHandler requestHandler = _restSOIHelper.FindRequestHandlerDelegate<IRequestHandler>();
130+
if (requestHandler != null)
131+
{
132+
return requestHandler.HandleStringRequest(Capabilities, request);
133+
}
134+
135+
//Insert error response here.
136+
return null;
137+
}
138+
139+
public byte[] HandleBinaryRequest2(string Capabilities, ref byte[] request)
140+
{
141+
IRequestHandler2 requestHandler = _restSOIHelper.FindRequestHandlerDelegate<IRequestHandler2>();
142+
if (requestHandler != null)
143+
{
144+
return requestHandler.HandleBinaryRequest2(Capabilities, request);
145+
}
146+
147+
//Insert error response here.
148+
return null;
149+
}
150+
#endregion
151+
152+
#region OGC interceptors
153+
public byte[] HandleStringWebRequest(esriHttpMethod httpMethod, string requestURL, string queryString, string Capabilities, string requestData, out string responseContentType, out esriWebResponseDataType respDataType)
154+
{
155+
IWebRequestHandler webRequestHandler = _restSOIHelper.FindRequestHandlerDelegate<IWebRequestHandler>();
156+
if (webRequestHandler != null)
157+
{
158+
return webRequestHandler.HandleStringWebRequest(
159+
httpMethod, requestURL, queryString, Capabilities, requestData, out responseContentType, out respDataType);
160+
}
161+
162+
responseContentType = null;
163+
respDataType = esriWebResponseDataType.esriWRDTPayload;
164+
//Insert error response here.
165+
return null;
166+
}
167+
#endregion
168+
}
169+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
6+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
7+
8+
<SignAssembly>true</SignAssembly>
9+
<AssemblyOriginatorKeyFile>mykey.snk</AssemblyOriginatorKeyFile>
10+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
11+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
12+
</PropertyGroup>
13+
14+
15+
<ItemGroup>
16+
<Reference Include="ESRI.Server.SOESupport">
17+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.SOESupport.dll</HintPath>
18+
<EmbedInteropTypes>false</EmbedInteropTypes>
19+
</Reference>
20+
<Reference Include="ESRI.Server.Carto">
21+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.Carto.dll</HintPath>
22+
<EmbedInteropTypes>false</EmbedInteropTypes>
23+
</Reference>
24+
<Reference Include="ESRI.Server.DatasourcesFile">
25+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.DatasourcesFile.dll</HintPath>
26+
</Reference>
27+
<Reference Include="ESRI.Server.DatasourcesGDB">
28+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.DatasourcesGDB.dll</HintPath>
29+
</Reference>
30+
<Reference Include="ESRI.Server.DatasourcesRaster">
31+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.DatasourcesRaster.dll</HintPath>
32+
</Reference>
33+
<Reference Include="ESRI.Server.Geodatabase">
34+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.Geodatabase.dll</HintPath>
35+
</Reference>
36+
<Reference Include="ESRI.Server.GeoDatabaseDistributed">
37+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.GeoDatabaseDistributed.dll</HintPath>
38+
</Reference>
39+
<Reference Include="ESRI.Server.GeoDatabaseExtensions">
40+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.GeoDatabaseExtensions.dll</HintPath>
41+
</Reference>
42+
<Reference Include="ESRI.Server.Geometry">
43+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.Geometry.dll</HintPath>
44+
</Reference>
45+
<Reference Include="ESRI.Server.GISClient">
46+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.GISClient.dll</HintPath>
47+
</Reference>
48+
<Reference Include="ESRI.Server.Server">
49+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.Server.dll</HintPath>
50+
</Reference>
51+
<Reference Include="ESRI.Server.System">
52+
<HintPath>$(ENTDEVKITJAVA)\DotNet\ESRI.Server.System.dll</HintPath>
53+
</Reference>
54+
</ItemGroup>
55+
56+
57+
<PropertyGroup>
58+
<ZipFileExtension>soe</ZipFileExtension>
59+
<AddInTargetProduct>Server</AddInTargetProduct>
60+
<AddInTargetVersion>11.0</AddInTargetVersion>
61+
<ServerProvider>ArcObjects11</ServerProvider>
62+
</PropertyGroup>
63+
<Import Project="$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.Enterprise.SDK.targets" Condition="Exists('$(MSBuildExtensionsPath)\ESRI\ESRI.ArcGIS.Enterprise.SDK.targets')" />
64+
65+
66+
67+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34408.163
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetFilterFeaturesByFieldSOI", "NetFilterFeaturesByFieldSOI.csproj", "{611E59A2-E1E4-4ED9-8CB6-D3FC2868A74B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{611E59A2-E1E4-4ED9-8CB6-D3FC2868A74B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{611E59A2-E1E4-4ED9-8CB6-D3FC2868A74B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{611E59A2-E1E4-4ED9-8CB6-D3FC2868A74B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{611E59A2-E1E4-4ED9-8CB6-D3FC2868A74B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {03749842-433E-4CE8-AA0B-4C18A780C712}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("ClipAndSpatialFilterSOI")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ClipAndSpatialFilterSOI")]
13+
[assembly: AssemblyCopyright("Copyright © 2022")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("b71a4fd2-5b82-4a19-8b3b-1d11389c151b")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
37+
38+
[assembly: ESRI.Server.SOESupport.AddInPackage("ClipAndSpatialFilterSOI", "cf479c85-ca82-4ff5-b546-809549c82a93",
39+
Author = "moha5225",
40+
Company = "",
41+
Date = "10/5/2019 1:38:08 PM",
42+
Description = "",
43+
TargetProduct = "Server",
44+
TargetVersion = "11.2",
45+
Version = "1.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
order: 14
3+
---
4+
5+
# .NET Filter Features By Field SOI
6+
7+
This sample illustrates how to develop an SOI to apply certain field value restrictions on the [Export Map](https://developers.arcgis.com/rest/services-reference/export-map.htm), [Identify](https://developers.arcgis.com/rest/services-reference/identify-map-service-.htm), and [Find](https://developers.arcgis.com/rest/services-reference/find.htm) REST operations of a map service. It contains a sample SOI called FilterFeaturesByFieldSOI. The FilterFeaturesByField SOI uses the ExportMap operation's "layerDefs" parameter to filter the displayed features by attribute field.
8+
9+
>*Note* : This sample SOI is only applicable to map services published from ArcGIS Pro to a 10.8 or later versions of ArcGIS Server. See [what's new in the ArcGIS REST API at 10.8](https://developers.arcgis.com/rest/services-reference/what-s-new.htm).
10+
11+
Deploying the SOI from the .soe file (`..\soe\NetFilterFeaturesByFieldSOI_ent.soe`) does not require you to open Visual Studio. However, you can load the project (`..\NetFilterFeaturesByFieldSOI.csproj`) in Visual Studio to debug, modify, and recompile the SOI code.
12+
13+
## Features
14+
15+
* Preprocess REST requests
16+
* Layer Definitions
17+
18+
## Sample data
19+
20+
This instruction uses the SampleWorldCities service as the sample service to test with the SOI.
21+
22+
## Instructions
23+
24+
### Deploy the SOIs
25+
26+
1. Log in to ArcGIS Server Manager and click the ***Site*** tab.
27+
2. Click ***Extensions***.
28+
3. Click ***Add Extension***.
29+
4. Click ***Choose File*** and choose the ***NetFilterFeaturesByFieldSOI_ent.soe*** file (`..\soe\NetFilterFeaturesByFieldSOI_ent.soe` or `..\bin\Debug\NetFilterFeaturesByFieldSOI_ent.soe`).
30+
5. Click ***Add***.
31+
32+
### Enable the FilterFeaturesByField SOI on a map service
33+
34+
1. Navigate to the SampleWorldCities map service in ArcGIS Server Manager.
35+
3. Select ***.NET FilterFeaturesByField SOI*** in the ***Available Interceptors*** box and click the right arrow button to move it to ***Enabled Interceptors***.
36+
4. Click the ***Save and Restart*** button to restart the service.
37+
38+
### Test the SpatialFilter SOI
39+
40+
1. Open a browser and navigate to the REST services endpoint of the SampleWorldCities map service (URL: `http://<serverdomain>/<webadaptorname>/rest/services/SampleWorldCities/MapServer`).
41+
2. Scroll to the bottom of the above page and click ***Export Map*** in ***Supported Extensions***.
42+
43+
This leads you to the following URL:
44+
45+
```
46+
http://<serverdomain>/<webadaptorname>/rest/services/SampleWorldCities/MapServer/export?bbox=-103.80966151584494,-40.27311509271942,74.63649935920162,66.70933645099878
47+
```
48+
49+
The exported image shows the map with only features that have a population (POP) over 500000. Alternatively, try to view this map service in ***ArcGIS JavaScript*** or ***ArcGIS Online Map Viewer*** and you should see similar result. (If the ***ArcGIS JavaScript*** or ***ArcGIS Online Map Viewer*** page appears blank at first, refresh the page or check sharing settings.)
50+
51+
3. You can play around the ***Export Map***, ***Identify*** and ***Find*** operations to observe the SOI's effects.
596 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)