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
Highlighted
Occasional Contributor
Posts: 9
Registered: ‎11-09-2015

New feature using Java API - part 2

[ Edited ]

Hi all,

 

a few days ago I wrote you about the need to add a feature to the legend using java API.

Thanks of your advices I could do that, but I still have two questions for you: 

 

  1. My feature is joined with different styles, based on the specific display rules. In the code I created an array of DisplayRule to add to the feature. In the map it is correctly visualized, but in the legend I can view the icon that represents more styles, but I cannot view the specific styles under the icon.  
  2. If one of these styles is new (previously added in the GMSC database by a workflow) I recivied this error:

 

  1. Caused by: com.intergraph.web.viewer.map.style.SymbologyConfigurationException: Can't find style '68f9c52d-ef9b-4c60-a854-37872ca3106e' in directory: C:\ProgramData\Intergraph\SmartClient\cache\GMSC\_symbology_\prj_DWH_Nitrati_library
    	at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.getStylePath(GFeatureTypeStyleManager.java:237)
    	at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.readStyleFromCache(GFeatureTypeStyleManager.java:179)
    	at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.loadStyle(GFeatureTypeStyleManager.java:119)
    	at com.intergraph.web.viewer.map.style.GFeatureTypeStyleManager.getStyle(GFeatureTypeStyleManager.java:110)
    	at com.intergraph.web.viewer.reader.gdoplus.GDOPlusFactory.getFeatureTypeStyle(GDOPlusFactory.java:180)
    	at com.intergraph.web.viewer.reader.gdoplus.StyleGroup.createStyleGroup(StyleGroup.java:49)

Someone knows how I can add the style to the cache.

 

This is my complete code to understand better: 

 

public boolean publishTheme(String symbologyIds, String symbologyNames, int simpleId, String name, String projectName, String entity, String themeName, int level)
	{
		try
		{
			Project project = ApplicationContext.getProject();
			
			Theme myTheme = project.getThemeByName(themeName);
			if (myTheme == null)
			{
				myTheme = Theme.createTheme(themeName, false, false);
				project.addThemeToProject(null, myTheme);
			}
			myTheme.setClosed(false);
			
			//tiling
			com.intergraph.services.emea._2011._03.types.TilingInfo ti = new com.intergraph.services.emea._2011._03.types.TilingInfo();
			ti.setColumns(1);
			ti.setRows(1);
			//scale range
			com.intergraph.services.emea._2011._03.types.ScaleRange sr = new com.intergraph.services.emea._2011._03.types.ScaleRange();
			sr.setFrom(new Long(0));
			sr.setTo(new Long(1000000000));
			//symbolgy
			com.intergraph.services.emea._2011._03.types.ArrayOfDisplayRule listDr = new com.intergraph.services.emea._2011._03.types.ArrayOfDisplayRule();
			String[] symbologyIdsArray = symbologyIds.split("#");
			String[] symbologyNamesArray = symbologyNames.split("#");
			for(int i = 0; i < symbologyIdsArray.length; i++)
			{
				com.intergraph.services.emea._2011._03.types.DisplayRule dr = new com.intergraph.services.emea._2011._03.types.DisplayRule();
				dr.setName(symbologyNamesArray[i]);
				dr.setSymbologyId(symbologyIdsArray[i]);
				listDr.getDisplayRule().add(dr);
			}
			
			
			com.intergraph.services.emea._2011._03.types.Feature feature = new com.intergraph.services.emea._2011._03.types.Feature();
			feature.setId(simpleId);
			feature.setName(name);
			feature.setDescription(name);
			feature.setGeometryType(GeometryTypes.AREA);
			feature.setMapInterpretaionType(MapInterpretationTypes.DEFAULT);
			feature.setKeyAttribute(key);
			feature.setTilingInfo(ti);
			feature.setBoundingBox(getBounds());
			feature.setScaleRange(sr);
			feature.setDisplayRules(listDr);
			feature.setFitFactor(new Float(1.25));
			feature.setOpacity(new Float(1));
			java.util.Date date= new java.util.Date();
			feature.setPublishTimestamp(new Timestamp(date.getTime()).getTime());
			feature.setLoaderId(loaderId);
			feature.setRightOnFeature(FeatureRight.ANALYZE);
			feature.setCopyright("");
			feature.setDataProjectName(projectName);
			feature.setIsSnapable(true);
			feature.setEntity(entity);
			
			project.addFeature(feature, myTheme, level);
			
			return true;
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			GUIToolkit.showInfo("Ex: " + e.getMessage());
			Log.getLogger().log(Level.SEVERE, e.getMessage(), e);
			return false;
		}
		
	}

Thanks all

 

Azzurra

Highlighted
Community Manager
Posts: 167
Registered: ‎10-09-2015

Re: New feature using Java API - part 2

Hi,

when you update the SymbologyLibrary in your workflow (add or modify a style), do you also update the timestamp?

The library will only be downloaded again on the client side, if the timestamps do not match. Also be aware of the fact that the libraries are downloaded on startup so if you add a style to the library using Workflows, you have to call 

 

GFeatureTypeStyleManager.reloadSymbologyLibraries()

 

to actually get the new style at runtime. 

To update the timestamp for the library in your Workflow you have to add these lines to your code (replace {YOURLIBRARY_ID} accordingly):

 

string symbologyLibraryId = {YOURLIBRARY_ID};
database.ExecuteNonQuery("Update RPI_SYMBOLOGYLIBRARY Set LIBRARYTIMESTAMP = @LIBRARYTIMESTAMP Where ID = @ID",
                new List<DataParameter>(){new DataParameter("LIBRARYTIMESTAMP", (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds),
                    new DataParameter("ID", symbologyLibraryId)});

 

Regards

Thomas

Thomas Anzinger
Community Manager
thomas.anzinger@hexagongeospatial.com
Highlighted
Occasional Contributor
Posts: 9
Registered: ‎11-09-2015

Re: New feature using Java API - part 2

Thanks a lot Thomas.

I'm going to try Smiley Happy

Azzurra

Highlighted
Occasional Contributor
Posts: 9
Registered: ‎11-09-2015

Re: New feature using Java API - part 2

Hi Thomas,

 

following your advice I can resolve the point 2, but not the point 1.

 

In the picture you can view the difference between a feature added using the administrator tools and one added by the code.

 

 

Legend

 

Someone can help me?

 

Thanks

Azzurra

Highlighted
Technical Evangelist
Posts: 166
Registered: ‎09-01-2015

Re: New feature using Java API - part 2

We have just reproduced the behavior and figured out that this is a Bug. While the feature is added as expected, the display rules are not handled in the legend when you use this method. Unfortunately there is no workaround that we can offer so you must wait until it is fixed in the product itself.


Alternatively you can create multiple features and add them to one theme instead of creating a thematic legend entry

 

Please report this bug in Siebel (https://siebweb.intergraph.com/service_enu/start.swe).