Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 49
Registered: ‎10-27-2015

Export selected PSS features - is it possible?

Hi All,

I am trying to export selected PSS features in the Geospatial Portal but no luck. I need geojson of the selected features. Is it possible at all? Any help?

Thank you very much.

Regards,

Denis

Contributor
Posts: 68
Registered: ‎02-10-2017

Re: Export selected PSS features - is it possible?

Hi Denis.

 

I think you  can do something like this to get geoJSON from selected features (example only for polygon):

 

$GP.selectedFeatures.find({}, function (ret) {
	//get only first feature
	var features = ret.features[0];
	var feature = features[0];

	feature.get_geoJSON(callback);

	function callback(a) {
		//return only if it's polygon
		if (a.geometry.type != "Polygon") { 
			alert("Geometry type not valid!");
		} else {
			$GP.ui.info(a);
		}
	}
});

HTH

António

Highlighted
Contributor
Posts: 49
Registered: ‎10-27-2015

Re: Export selected PSS features - is it possible?

Hi Antonio,

your method doesn't work. It is when get_geoJSON() is called I get the error

 

Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:439 Uncaught TypeError: Cannot read property 'get_features' of null
    at a (Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:439)
    at a.MapService._requestCompleted (Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:1037)
    at Array.<anonymous> (Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:5)
    at Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:5
    at Sys.Net.WebRequest.completed (Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:5)
    at XMLHttpRequest._onReadyStateChange (Compositor.WebClient.ashx?p=%2fportal%2fFull.aspx&e=en-GB.release.js&t=636483271835705992:5)

 

Regards,

Denis

Contributor
Posts: 68
Registered: ‎02-10-2017

Re: Export selected PSS features - is it possible?

[ Edited ]

Hi Denis.

 

I've tested it and it is working.

There was one problem and it was when displaying the information:

$GP.ui.info(a);

If you replace that line by 

$GP.ui.info(Sys.Serialization.JavaScriptSerializer.serialize(a));

 it will work.

 

 It seems, by the message in your error that you don't have any feature in selected set.

Contributor
Posts: 49
Registered: ‎10-27-2015

Re: Export selected PSS features - is it possible?

Hi Antonio,

 

if I manually create PSS, feature class and features then it works but I am creating PSS via API like so

 

function addPSS(json) {
       json = $GP.utils.deserialize(JSON.stringify(json));
	var featureCollectionsData = [{
		featureClassId: "pssData1",
		featureClassName: "PSS featureClass imported from geojson",
		geojson: json
	}];
	
	$GP.edit.PSS.add(
	{
		name: "ImportedPSS"
	}, 
	function pssCreated(result1) {
		$GP.edit.features.importFeatureCollections(
		{
			mapServiceId: result1.mapServiceId,
			featureCollectionsData: featureCollectionsData
		}, 
		function featureCollectionImported(result2) {
			$GP.legend.add(
			{
				mapServiceId: result1.mapServiceId,
				ids: result2.featureClassIds
			}, 
			function legendItemsAdded(result3) {    
			});
		});
	});	
}

 

and then if I select features from this PSS and try to export using your method I get the error. So there is something broken somewhere  in the API.

 

Thanks

Denis

 

 

 

 

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.