M.App Enterprise Discussions

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Regular Contributor
Posts: 192
Registered: ‎03-04-2016
Accepted Solution

Publish raster data to content using js

Hello Community,

 

Is it possible to publish data into the content via code?

Is there a sample or documentation somewhere?

And if not, are there alternatives?

 

 

Kind regards

Elodie

 

Highlighted
Technical Evangelist
Posts: 1,374
Registered: ‎09-11-2015

Re: Publish raster data to content using js

[ Edited ]

Hi Elodie,

 

The Studio API is not documented at the moment, at least not publicly AFAIK. However, if you have a DB connection present in M.App Studio, it should be pretty easy to read the network traffic. E.g. when creating a new cached vector data you require POST like this + provide the token:

 

The geometry type numbering should be possible to guess from existing content.

[{
      "connectionId": "d60ab4f5-c919-48f9-cc84-ee3f4599aba9",
      "import": {
         "dimension": 2,
         "srid": 26918,
         "tableName": "airports",
         "columnName": "geometry",
         "geometryType": 4
      },
      "isCached": true,
      "name": "airports",
      "srid": 26918
   }
]

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Staff
Posts: 1,127
Registered: ‎10-18-2015

Re: Publish raster data to content using js

Hi Elodie,

 

you can see the list of methods provided by Studio API using the swagger documentation (you cannot currently test the methods directly in there since it does not support authentication):

https://YOURSERVER/swagger/ui/index 

 

Here is a sample code to publish an imagery into Studio content:

// registers a new Imagery into Studio content and sends it to a Map panel
function setImagery(imageName) {
  var studiouser = 'Admin';
  var studiopwd = 'Admin';
  var requestData= {
		name: imageName.split('.')[0],
		physicalPath: "\\\\UNCPATH\\" + imageName,
		minScale: null,
		maxScale: null,
		isEcwp: false,
		isWmts: false,
		isWms: true
	};
  var token = login(studiouser,studiopwd,'Studio').done(function (result) {
  var headers = {'Tenant': queryDict.tenant, 'Authorization': 'Bearer ' + token.responseJSON.access_token};
      $.ajax({
		 url: '/api/v1/studio/content/imagery',
		 type: 'POST',
		 headers: headers,
		 data: requestData,
		 success: function(data,statusText, resObject){
			// sends message to the Map panel to show the registered imagery using the Apollo Core default service
			gsp.m_app.messages.send(
				"WKE.AddLegendItem", {
				componentName: "map",
				definitionName: "WMS",
				url: "/erdas-iws/ogc/wms/" + TENANTNAME + "?",
				layerName: imageName,
				name: imageName,
				// bbox may be got from the WMS getCapabilities
				bbox: [-81.97123374329497, 28.886115030959626, -81.95452507901035, 28.898817009870736],
				bboxCrs: "EPSG:4326", 
				supportedCrses: ["EPSG:4326","EPSG:3857"]
				}
			);
		  },
		error: function(errMsg) {
                alert('error');
                console.log(errMsg);
            } 
    })
  });
}

HTH,

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial