Show DGN/DWG/SHP file over the ArcGIS JS map viewer

3825
4
04-04-2017 10:38 PM
SreejithSreenivasan
New Contributor II

We have an ArcGIS java script web application. We need to add a functionality to allow the user to upload the Drawing file (DGN/DWG/SHP) from the client browser and Zoom into the drawing file location and display the drawing as a map service. It should be on the fly and it should maintain the symbology.

Any suggestions?  

4 Replies
PanagiotisPapadopoulos
Esri Regular Contributor

A possible solution is to create a geoprocessing service  for upload and convert the files to features

the following example used foe convert the DWG to features


import glob, zipfile, arcpy

def dwgToFeatures(dwgFile):
arcpy.AddMessage("dwgToFeatures")
arcpy.CADToGeodatabase_conversion(dwgFile, arcpy.env.scratchGDB, "DWGTestData_CADToGeodatabase", "204657", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 11258999068426,2;-1073,7418235 4194304001953,12;-100000 10000;8,98315284119522E-09;0,001;0,001;IsHighPrecision")
return arcpy.env.scratchGDB + "/DWGTestData_CADToGeodatabase/Polygon"

def ProcessInput():
sourceDWGFile = arcpy.GetParameterAsText(0)
outputFeatureClass = dwgToFeatures(sourceDWGFile)
arcpy.SetParameterAsText(1, outputFeatureClass)

ProcessInput()

then on the Javascript application create the Upload Form

sent the uploaded file on the geoprocessing service and get the result features (don't forget to enable the upload service on the geoprocessing service)

you can add the result features on a graphic layer on the map and/or apply the geometries on a feature service in order to store on the geodatabase.

SAMPLE JS code to sent the file on the upload service

---------------------------------------------------------------------------------------------------

var requestHandle = esri.request({
url: "GEOPROCESSING SERVICE URL",
form: dojo.byId("uploadForm"),
content: { f: "json" },
handleAs: "json",
load: uploadSucceeded,
error: uploadFailed
});

SAMPLE JS code to sent the request on the geoprocessing service

---------------------------------------------------------------------------------------------------

function uploadSucceeded(response, io) {

......

if(filetype === 'dwg'){
var params= { "uploadDWGFile": "{'itemID':" + itemID + "}" };
gpTaskdwg.setOutSpatialReference({wkid:102100});
gpTaskdwg.execute(params, displayResult, errorGP);
}

....

}

PanagiotisPapadopoulos
Esri Regular Contributor

Also the Web App Builder can use this Geoprocessing service creating the upload UI and the show results UI.

0 Kudos
SreejithSreenivasan
New Contributor II

Thanks for you reply.Can we maintain the symbology once we have convert the file using GP.The drawing files have complex features and symbology. 

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

When publishing a geoprocessing service, you can choose to view the result of all tasks within the service as a map, see here

Geoprocessing service settings: Parameters—Documentation | ArcGIS Enterprise 

Alternative you can store the results on a feature class (apply edits) and use this feature class on a dynamic service (use complex symbology).

The results can be filtered (using definition query) base on a attribute you will calculate.