davetimmins / arcgis.pcl Goto Github PK
View Code? Open in Web Editor NEWMigrated to https://github.com/davetimmins/Anywhere.ArcGIS
License: MIT License
Migrated to https://github.com/davetimmins/Anywhere.ArcGIS
License: MIT License
It would be useful to have a description of the layers of a mapservice, to determine the geometry for example
10.3 now has resultOffset and resultRecordCount for supporting paging http://resources.arcgis.com/en/help/arcgis-rest-api/#/Query_Feature_Service_Layer/02r3000000r1000000/
It would be useful to include this property ObjectIds as comma delimited string.
Do you think that adding the following code to Query class can work?
[DataMember(Name = "objectIds")]
public String ObjectIds { get; set; }
Need a set of decent test data to verify what works.
Sometimes the integration tests fail as they reference ArcGIS server services that have gone idle and therefore fail trying to access them (this is a known AGS issue with older versions of server). Rather than trying to look for new services to test against we can use https://github.com/giggio/xunit-retry for these tests.
Often times as we run various rules, we need to get the geometry for sole reason to pass it to another query. At that time we do not know the geometry type nor do we care what it is. Would it be possible to have a Query method that does not specify type of geometry?
For now I created a workaround via custom serializer as a proof that the feature is doable. I pasted the class below
`using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using ArcGIS.ServiceModel;
using ArcGIS.ServiceModel.Common;
using ArcGIS.ServiceModel.Operation;
using Newtonsoft.Json.Linq;
namespace ArcGisIntegration.Services
{
public class ArcGisSerializer : ISerializer
{
private static ISerializer _serializer = null;
public static void Init(Newtonsoft.Json.JsonSerializerSettings settings = null)
{
_serializer = new ArcGisSerializer(settings);
SerializerFactory.Get = (() => _serializer ?? new ArcGisSerializer(settings));
}
private readonly Newtonsoft.Json.JsonSerializerSettings _settings;
public ArcGisSerializer(Newtonsoft.Json.JsonSerializerSettings settings = null)
{
_settings = settings ?? new Newtonsoft.Json.JsonSerializerSettings
{
NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore,
StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeHtml,
TypeNameHandling = Newtonsoft.Json.TypeNameHandling.None
};
}
public Dictionary<string, string> AsDictionary<T>(T objectToConvert) where T : CommonParameters
{
var stringValue = Newtonsoft.Json.JsonConvert.SerializeObject(objectToConvert, _settings);
var jobject = Newtonsoft.Json.Linq.JObject.Parse(stringValue);
var dict = new Dictionary<string, string>();
foreach (var item in jobject)
{
dict.Add(item.Key, item.Value.ToString());
}
return dict;
}
public T AsPortalResponse<T>(string dataToConvert) where T : IPortalResponse
{
// got generic geometry in the API
if (typeof(T) == typeof(QueryResponse<IGeometry>))
{
var preliminaryData = JObject.Parse(dataToConvert);
var type = preliminaryData.GetValue("geometryType").Value<string>();
switch (type)
{
case "esriGeometryEnvelope":
return (T)CreateResponce(AsPortalResponse<QueryResponse<Extent>>(dataToConvert));
case "esriGeometryMultipoint":
return (T)CreateResponce(AsPortalResponse<QueryResponse<MultiPoint>>(dataToConvert));
case "esriGeometryPoint":
return (T)CreateResponce(AsPortalResponse<QueryResponse<Point>>(dataToConvert));
case "esriGeometryPolygon":
return (T)CreateResponce(AsPortalResponse<QueryResponse<Polygon>>(dataToConvert));
case "esriGeometryPolyline":
return (T)CreateResponce(AsPortalResponse<QueryResponse<Polyline>>(dataToConvert));
default:
throw new ArgumentException(
"AsPortalResponse - cannot support IGeometry for value returned type of " + type);
}
}
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(dataToConvert, _settings);
}
private IPortalResponse CreateResponce<TResponce>(QueryResponse<TResponce> responce)
where TResponce : IGeometry
{
var features = new List<Feature<IGeometry>>();
responce.Features.ToList().ForEach(one => features.Add(new Feature<IGeometry>
{
Attributes = one.Attributes,
Geometry = one.Geometry
}));
var result = new QueryResponse<IGeometry>
{
DisplayFieldName = responce.DisplayFieldName,
Error = responce.Error,
ExceededTransferLimit = responce.ExceededTransferLimit,
Features = features,
FieldAliases = responce.FieldAliases,
Fields = responce.Fields,
GeometryTypeString = responce.GeometryTypeString,
GlobalIdFieldName = responce.GlobalIdFieldName,
Links = responce.Links,
ObjectIdFieldName = responce.ObjectIdFieldName,
SpatialReference = responce.SpatialReference
};
return result;
}
}
}`
Not sure if this is just me, so close if necessary.
When cloning repository and trying to build in Visual Studio 2012 (v 11.0.50727.1 RTMREL), the ArcGIS.ServiceModel and ArcGIS.Test projects fail to load.
Error:
C:\dev\ArcGIS.PCL\ArcGIS.ServiceModel\ArcGIS.ServiceModel.csproj : error : The imported project "C:\dev\ArcGIS.PCL\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\dev\ArcGIS.PCL\ArcGIS.ServiceModel\ArcGIS.ServiceModel.csproj
C:\dev\ArcGIS.PCL\ArcGIS.Test\ArcGIS.Test.csproj : error : The imported project "C:\dev\ArcGIS.PCL\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\dev\ArcGIS.PCL\ArcGIS.Test\ArcGIS.Test.csproj
Removing the following lines from the respective .csproj files resolves this issue and allows me to build...
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets" />
...however 10 out of 14 tests then fail for an assembly load failure.
After successful build, adding the above line back into the .csproj file no longer causes the project load failure, and also allows most of the tests to pass.
Hi,
I'm working on a routing prototype, and the "solve" operation is not yet implemented in ArcGis.PCL. I can propose to do the job, as I will need it for my project.
Make it easier to check how many of the passed in adds / updates and deletes were successful
The current way of resolving ISerializer
, HttpClient
etc. is pretty limited so need to investigate a better way of doing this.
Probably be better as a separate operation
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Query_Feature_Service_Layer/02r3000000r1000000/
Use something like https://github.com/tavis-software/Tavis.UriTemplates
Reading Paul Betts blog it seems I'm doing it wrong.
Thinking I can rip out all the non platform stuff and have that as a truly portable dll and then reference that from the bait and switch version. So will end up with 2 portable solutions though one will have all the platform specific stuff in it.
This will also allow the encryption to be done properly from issue #6
I was a bit lazy initially and since these files have grown quite large they need separating.
Not all versions of server support this so by making ResultOffset nullable it will be omitted from the request by default.
Would be great to be able to easily delete WHERE global='xxxxx'. Right now I have to query the objectid, then do an ApplyEdits with the objectId to delete.
Currently the Travis-CI build errors when trying to discover tests with the error
536System.TypeLoadException: Could not load type 'Xunit.Sdk.XunitTestFrameworkDiscoverer, xunit.execution, Version=2.0.0.2785, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'
Related to xunit/xunit#158
We ran into a small issue. Query method is hard-coded to use 2047 to decide if POST or GET should be used. We encountered some use cases, where people customize config to allow for a smaller request size. At that point we would get errors on certain (long body) requests. Would it be possible to make this number configurable instead of hard-coded, and just default to 2047 if not configured?
Thank you!
Currently these just have a PointCollectionList for their Paths and Rings, should be an array instead. Need to check how it would affect the serialization. This needs to filter through to the GeoJSON conversions too.
Right now there is a single solution which requires the build to have access and licenses to Xamarin, etc... It would be good to have .NET only solution, so that we can easily build .NET only version of the package.
Allow usage of the server info from rest/info to be used automatically for things like the token service. You can do this now be calling the methods yourself but this would make it simpler.
When describing a service, Advanced Query Capabilities node is not included in the response. Here is how it looks in the browser when hitting a service.
Advanced Query Capabilities:
Supports Statistics: true
Supports OrderBy: true
Supports Distinct: true
Supports Pagination: false
Supports TrueCurve: true
There are lots of missing pages, placeholders in sidebar need filling in
Add LibLog so requests and errors are logged using the users log framework of choice
If ArcGIS Server is federated with Portal then you can generate a token using the geneerateToken operation for the Portal token service. Just a matter of specifying the serverUrl request parameter.
As of ArcGIS Server 10.1 it is possible to pass an encrypted payload when generating tokens. An example is shown here.
Since the RSA crypto library isn't available as a PCL it will need to be done per client in a similar way to serialization. One way this could work is to have an optional crypto provider that can be passed to the TokenProvider constructor and if it is set then it requests an encrypted payload, otherwise it works as is in the CheckGenerateToken method. Something like this?
protected async Task<Token> CheckGenerateToken()
{
if (TokenRequest == null) return null;
_token = null; // reset the Token
CheckRefererHeader();
var url = TokenRequest.BuildAbsoluteUrl(RootUrl).Split('?').FirstOrDefault();
Uri uri;
bool validUrl = Uri.TryCreate(url, UriKind.Absolute, out uri);
if (!validUrl)
throw new HttpRequestException(String.Format("Not a valid url: {0}", url));
HttpContent content = null;
if (_crypto != null)
{
Uri encryptionInfoEndpoint = new Uri(RootUrl, "publicKey");
var ei = await GetStringAsync(encryptionInfoEndpoint, addToken: false);
byte[] exponent = EncodingHelper.HexToBytes(ei["publicKey"].Value<string>());
byte[] modulus = EncodingHelper.HexToBytes(ei["modulus"].Value<string>());
var encryptedTokenRequest = new GenerateToken(
EncodingHelper.BytesToHex(_crypto.Encrypt(exponent, modulus, Encoding.UTF8.GetBytes(TokenRequest.Username), false)),
EncodingHelper.BytesToHex(_crypto.Encrypt(exponent, modulus, Encoding.UTF8.GetBytes(TokenRequest.Password), false)));
content = new FormUrlEncodedContent(Serializer.AsDictionary(encryptedTokenRequest));
}
else content = new FormUrlEncodedContent(Serializer.AsDictionary(TokenRequest));
_httpClient.CancelPendingRequests();
HttpResponseMessage response = await _httpClient.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
var resultString = await response.Content.ReadAsStringAsync();
System.Diagnostics.Debug.WriteLine("Generate token result: " + resultString);
var result = Serializer.AsPortalResponse<Token>(resultString);
if (result.Error != null) throw new InvalidOperationException(result.Error.ToString());
_token = result;
if (!String.IsNullOrWhiteSpace(TokenRequest.Referer)) _token.Referer = TokenRequest.Referer;
return _token;
}
Is there a way to pass in a custom logger on ArcGIS.PCL without building the project with the pre-condition values?
Hi,
As we use this library, we want to get total count only for a query and now it is missing in the Query and QueryResponse class. I think just need to add Count property into QueryResponse class and ReturnCountOnly property into Query class.
Thanks
This package is part of core .NET 4.5, and can be removed. It adds Microsoft.Bcl reference, and there is no reason to have this in .NET 4.5. Should this be fixed?
Currently I just try to send the POST but for large payloads this will error and then I send as MultipartFormDataContent. Should instead check the POST content length and if longer than 65520 characters then just use MultipartFormDataContent see https://github.com/davetimmins/ArcGIS.PCL/blob/master/src/ArcGIS.ServiceModel/PortalGatewayBase.cs#L383
how do i add orderBy to query?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.