**CROSS-POST** I originaly posted this in the Dev community, but I think it also belongs here.
--
I've created a single shape (wkid: 102100) with 4 vertices in a shapefile.
When I run that shapefile through an analyze operation on my local Portal machine, I get the following response:
{
"publishParameters": {
"type": "shape",
"name": "cadastre_wgs84wm_digitised",
"sourceUrl": "",
"maxRecordCount": -1,
"targetSR": {
"wkid": 102100,
"latestWkid": 3857
},
"editorTrackingInfo": {
"enableEditorTracking": false,
"enableOwnershipAccessControl": false,
"allowOthersToUpdate": true,
"allowOthersToDelete": false
},
"layerInfo": {
"currentVersion": 11.1,
"id": 0,
"name": "cadastre_wgs84wm_digitised",
"type": "Feature Layer",
"displayField": "",
"description": "",
"copyrightText": "",
"defaultVisibility": true,
"editFieldsInfo": null,
"relationships": [],
"isDataVersioned": false,
"supportsRollbackOnFailureParameter": true,
"supportsAdvancedQueries": true,
"supportsValidateSQL": true,
"supportsCalculate": true,
"advancedQueryCapabilities": {
"supportsReturningQueryExtent": true,
"supportsStatistics": true,
"supportsDistinct": true,
"supportsPagination": true,
"supportsOrderBy": true,
"supportsQueryWithDistance": true
},
"geometryType": "esriGeometryPolygon",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [
202,
252,
208,
255
],
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
110,
110,
110,
255
],
"width": 0.4
}
},
"label": "",
"description": ""
}
},
"hasM": false,
"hasZ": false,
"allowGeometryUpdates": true,
"hasAttachments": false,
"htmlPopupType": "esriServerHTMLPopupTypeNone",
"supportsApplyEditsWithGlobalIds": true,
"objectIdField": "FID",
"globalIdField": "",
"typeIdField": "",
"fields": [
{
"name": "FID",
"type": "esriFieldTypeOID",
"alias": "FID"
},
{
"name": "Id",
"type": "esriFieldTypeInteger",
"alias": "Id"
}
],
"types": [],
"templates": [
{
"name": "New Feature",
"description": "",
"drawingTool": "esriFeatureEditToolPolygon",
"prototype": {
"attributes": {
"Id": null
}
}
}
],
"useStandardizedQueries": true,
"enableZDefaults": false,
"zDefault": 0,
"supportedQueryFormats": "JSON",
"hasStaticData": false,
"maxRecordCount": -1,
"capabilities": "Create,Delete,Query,Update,Editing",
"supportsCoordinatesQuantization": false,
"supportsAttachmentsByUploadId": true,
"minScale": 0,
"maxScale": 0,
"extent": {
"xmin": 12895760.54079283,
"ymin": -3755035.285140656,
"xmax": 12895774.872848857,
"ymax": -3754980.687832646,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
}
}
},
"records": [
{
"attributes": {
"FID": 0,
"Id": 0
}
}
],
"fileSize": 3018
}
I subsequently run the same shapefile through a generate operation, with the publishedParameters from the response to the analyze operation. That gives the following output:
{
"featureCollection": {
"layers": [
{
"layerDefinition": {
"currentVersion": 11.1,
"id": 0,
"name": "cadastre_wgs84wm_digitised",
"displayField": "",
"description": "",
"copyrightText": "",
"defaultVisibility": true,
"editFieldsInfo": null,
"relationships": [],
"isDataVersioned": false,
"supportsRollbackOnFailureParameter": true,
"supportsAdvancedQueries": true,
"supportsValidateSQL": true,
"supportsCalculate": true,
"advancedQueryCapabilities": {
"supportsReturningQueryExtent": true,
"supportsStatistics": true,
"supportsDistinct": true,
"supportsPagination": true,
"supportsOrderBy": true,
"supportsQueryWithDistance": true
},
"geometryType": "esriGeometryPolygon",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [
206,
210,
242,
255
],
"outline": {
"type": "esriSLS",
"style": "esriSLSSolid",
"color": [
110,
110,
110,
255
],
"width": 0.4
}
},
"label": "",
"description": ""
}
},
"hasM": false,
"hasZ": false,
"allowGeometryUpdates": true,
"hasAttachments": false,
"htmlPopupType": "esriServerHTMLPopupTypeNone",
"supportsApplyEditsWithGlobalIds": true,
"globalIdField": "",
"typeIdField": "",
"types": [],
"templates": [
{
"name": "New Feature",
"description": "",
"drawingTool": "esriFeatureEditToolPolygon",
"prototype": {
"attributes": {
"Id": null
}
}
}
],
"useStandardizedQueries": true,
"enableZDefaults": false,
"zDefault": 0,
"supportedQueryFormats": "JSON",
"hasStaticData": false,
"maxRecordCount": -1,
"capabilities": "Create,Delete,Query,Update,Editing",
"supportsCoordinatesQuantization": false,
"supportsAttachmentsByUploadId": true,
"fields": [
{
"name": "FID",
"type": "esriFieldTypeOID",
"alias": "FID"
},
{
"name": "Id",
"type": "esriFieldTypeInteger",
"alias": "Id"
}
],
"objectIdField": "FID",
"minScale": 0,
"maxScale": 0,
"extent": {
"xmin": 12895760.54079283,
"ymin": -3755035.285140656,
"xmax": 12895774.872848857,
"ymax": -3754980.687832646,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"type": "Feature Layer"
},
"featureSet": {
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"features": [
{
"attributes": {
"FID": 0,
"Id": 0
},
"geometry": {
"rings": [
[
[
12895760.665251553,
-3754980.687832646
],
[
12895774.872848857,
-3754980.7207584456
],
[
12895774.751507085,
-3755035.285140656
],
[
12895760.54079283,
-3755035.2522147074
],
[
12895760.665251553,
-3754980.687832646
]
]
],
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
}
}
]
}
}
],
"showLegend": true
}
}
This results in a shape with 5 vertices.
"features": [
{
"attributes": {
"FID": 0,
"Id": 0
},
"geometry": {
"rings": [
[
[
12895760.665251553,
-3754980.687832646
],
[
12895774.872848857,
-3754980.7207584456
],
[
12895774.751507085,
-3755035.285140656
],
[
12895760.54079283,
-3755035.2522147074
],
[
12895760.665251553,
-3754980.687832646
]
]
],
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
}
}
]
Can anyone tell me why my input shape with 4 vertices has been distorted in such a way that it now has 5 vertices? Throughout these operations the spatial references have, to my knowledge, all been set to WKID: 102100, so I don't beleive any transformations (should) have been applied to the data.
Any help understanding what is happening here would be appreciated.
Thanks!
Solved! Go to Solution.
@DavidHorsey If you look at the coordinates the first point and the last point are the same. When a polygon is represented in JSON it is called a "ring". It's not a ring or closed polygon unless the first point and the last point are the same. If the fifth point were ommitted from the JSON it would be just a line with a start point, 2 vertices and an end point.
Cheers,
Bernie.
@DavidHorsey If you look at the coordinates the first point and the last point are the same. When a polygon is represented in JSON it is called a "ring". It's not a ring or closed polygon unless the first point and the last point are the same. If the fifth point were ommitted from the JSON it would be just a line with a start point, 2 vertices and an end point.
Cheers,
Bernie.
Thanks @berniejconnors. That answers my question, but not my problem 😂 I have a legitimate problem where shapefiles uploaded to an application are getting slightly distorted. I was manually working through the process, e.g. using the analyze and generate operations and checking the results, when I came across the situation above and thought this was the root of my problems.
Thanks for taking the time to answer my question, at least I've learnt JSON rspresentations of shapes have n+1 vertices. I'll keep working through my issue and, depending on what I find out, might lean on the community for more help. Watch this space...😀
If you are seeing slight distortions it could be a reprojection of your data. What is the map projection of your shapefiles? If it is not web mercator your shape files are likely being reprojected to match the map projection of your basemap. The AGOL basemaps use the web mercator projection.
Bernie.