Hi,
I am developing a simple SOI to hide some attributes. The environment is 10.8.1 and the service is shared on AGS with copy data e feature access.
The request is very simple:
.....
public byte[] handleRESTRequest(String capabilities, String resourceName, String operationName,
String operationInput, String outputFormat, String requestProperties, String[] responseProperties)
throws IOException, AutomationException {
try {
IRESTRequestHandler restRequestHandler = soiHelper.findRestRequestHandlerDelegate(so);
if (restRequestHandler != null) {
if (operationName != null && operationName.equals("query")) {
byte[] originalResponse = restRequestHandler.handleRESTRequest(capabilities, resourceName,
operationName, operationInput, outputFormat, requestProperties, responseProperties);
// parse response and hide attributes
.....
The problem is that the outputFormat is "pbf", i.e. I cannot convert the reponse to JSON. If I set "json" before the call, than the response is ok but the caller expects "pbf" so it won't work.
Here there is the solution for Javascript, but I cannot figure out how to solve it in java. Is there a way to avoid to have a request for pbf or a conversion pbf2json ?
Thanks
Gianni
UPDATE: Even if I intercept the "info" request (resourceName, operationName and operationInput are empty) and modifying the supportedQueryOutputs from "JSON, GeoJSON,PBF "to "JSON, GeoJSON" the problem is not solved.
Solved! Go to Solution.
Ciao Gianni,
The FeatureCollection is an encoding of feature geographic and attribute data structures using the Protocol Binary Format (PBF). Notably, the FeatureCollection is an alternative encoding of a FeatureSet, ESRI's JSON encoding of Feature objects. Not only are FeatureCollections serialized differently through the use of a new binary specification, but they also have fundamental structural differences that developers will need to account for.
here you can see the initial specification arcgis-pbf/proto/FeatureCollection at main · Esri/arcgis-pbf · GitHub
you can generate your class in for example c#
protoc.exe FeatureCollection.proto --csharp_out=C:/Temp/Scratch/out --proto_path=c:/Temp/Scratch/pbf
you can download protoc.exe here Release Protocol Buffers v3.17.2 · protocolbuffers/protobuf · GitHub
FeatureCollection.proto ( https://raw.githubusercontent.com/Esri/arcgis-pbf/main/proto/FeatureCollection/FeatureCollection.pro... )
then with your class generated you can write similar code to deserialize pbf:
FeatureCollectionPBuffer f = (File.ReadAllBytes(@"C:\Temp\Scratch\pbf\query")).ToObject<FeatureCollectionPBuffer>();
public static T ToObject<T>(this byte[] buf) where T : IMessage<T>, new()
{
if (buf == null)
return default(T);
using (MemoryStream ms = new MemoryStream())
{
ms.Write(buf, 0, buf.Length);
ms.Seek(0, SeekOrigin.Begin);
MessageParser<T> parser = new MessageParser<T>(() => new T());
return parser.ParseFrom(ms);
}
}
Ciao Gianni,
The FeatureCollection is an encoding of feature geographic and attribute data structures using the Protocol Binary Format (PBF). Notably, the FeatureCollection is an alternative encoding of a FeatureSet, ESRI's JSON encoding of Feature objects. Not only are FeatureCollections serialized differently through the use of a new binary specification, but they also have fundamental structural differences that developers will need to account for.
here you can see the initial specification arcgis-pbf/proto/FeatureCollection at main · Esri/arcgis-pbf · GitHub
you can generate your class in for example c#
protoc.exe FeatureCollection.proto --csharp_out=C:/Temp/Scratch/out --proto_path=c:/Temp/Scratch/pbf
you can download protoc.exe here Release Protocol Buffers v3.17.2 · protocolbuffers/protobuf · GitHub
FeatureCollection.proto ( https://raw.githubusercontent.com/Esri/arcgis-pbf/main/proto/FeatureCollection/FeatureCollection.pro... )
then with your class generated you can write similar code to deserialize pbf:
FeatureCollectionPBuffer f = (File.ReadAllBytes(@"C:\Temp\Scratch\pbf\query")).ToObject<FeatureCollectionPBuffer>();
public static T ToObject<T>(this byte[] buf) where T : IMessage<T>, new()
{
if (buf == null)
return default(T);
using (MemoryStream ms = new MemoryStream())
{
ms.Write(buf, 0, buf.Length);
ms.Seek(0, SeekOrigin.Begin);
MessageParser<T> parser = new MessageParser<T>(() => new T());
return parser.ParseFrom(ms);
}
}
Hi nicogis,
thanks for solution!
An update to my issue: the pbf response is returned only with Feature Services, not with Map Services.
Regarding the protoc generator and Esri's specs (for example decoded coordinates are integers that must be transformed again) I think it wold be great if Esri could implement a set of API to simplify encoding/decoding.
Grazie
Ciao