Tuesday, 15 March 2022

ArcCatalog - deleted feature class reappears (Enterprise Geodatabase)

I tried to delete Oracle views in ArcCatalog but as soons as I reconnected the feature class reappeared in ArcCatalog.

It seems that if the view is invalid in Oracle ArcCatalog can't delete it. You need to modify the view so that it becomes valid again before deleting.

ArcMap/ArcCatalog 10.7.1, Oracle 11g

Geonis Interlis Export - ORA-24550: signal received: Unhandled exception: Code=e0434352 Flags=1 - revisted

Coming back to a post from 2019:

ORA-24550: signal received: Unhandled exception: Code=e0434352 Flags=1

The message doesnt help that much and hides the error message generated by the application. The message seems to be part of some kind of diagnostics which is enabled by default in some circumstances in Oracle client. It can be turned off by adding the following setting to sqlnet.ora

DIAG_SIGHANDLER_ENABLED=FALSE

After turning it off I got a more helpful error stack trace:

Unhandled Exception: GEONIS.Core.ErrorHandling.GTranslateableException: Could not open Table [VMG.VMG_V_VER_FLA_ART] ---> System.Runtime.InteropServices.COMException: DBMS-Tabelle nicht gefunden [ORA-24372: Ungültiges Objekt für Beschreibung]

   at ESRI.ArcGIS.Geodatabase.IFeatureWorkspace.OpenTable(String Name)

   ....


Tuesday, 21 September 2021

Hide single features in ArcMap

Here is a Python tool to hide selected features in ArcMap and to bring them back to screen. Useful if you need to create a screenshot / printout but want to hide certain features but not a whole layer. The tool applies a definition filter to "hide" selected features (across multiple layers) and removes the filters to display the features again. Filter condition is added to existing query.

Initial idea found on gis.stackexchange:

https://gis.stackexchange.com/questions/368848/creating-definition-query-from-selected-features-using-arcgis-pro

First the toolbox definition - save as PYT file:

 # -*- coding: utf-8 -*-  
 """  
 Created on Fri Feb 28 08:49:34 2020  
 """  
 import arcpy , m_main_layer  
 class Toolbox(object):  
   def __init__(self):  
     """Define the toolbox (the name of the toolbox is the name of the .pyt file)."""  
     self.label = "My Toolbox"  
     self.alias = ""  
     # List of tool classes associated with this toolbox  
     self.tools = [FeatureOff, FeatureOn]  
 class FeatureOff(object):  
   def __init__(self):  
     """Define the tool (tool name is the name of the class)."""  
     self.label = "Hide selected features"  
     self.description = "Hides selected features by applying a layer definition query"  
     self.canRunInBackground = False  
   def getParameterInfo(self):  
     """Define parameter definitions"""  
     return  
   def isLicensed(self):  
     """Set whether tool is licensed to execute."""  
     return True  
   def updateParameters(self, parameters):  
     """Modify the values and properties of parameters before internal  
     validation is performed. This method is called whenever a parameter  
     has been changed."""      
     return  
   def updateMessages(self, parameters):  
     """Modify the messages created by internal validation for each tool  
     parameter. This method is called after internal validation."""  
     return  
   def execute(self, parameters, messages):      
     reload(m_main_layer)       
     m_main_layer.main_off()  
     return  
 class FeatureOn(object):  
   def __init__(self):  
     """Define the tool (tool name is the name of the class)."""  
     self.label = "Display hidden features"  
     self.description = "displays hidden features by removing layer definition query"  
     self.canRunInBackground = False  
   def getParameterInfo(self):  
     """Define parameter definitions"""  
     return  
   def isLicensed(self):  
     """Set whether tool is licensed to execute."""  
     return True  
   def updateParameters(self, parameters):  
     """Modify the values and properties of parameters before internal  
     validation is performed. This method is called whenever a parameter  
     has been changed."""      
     return  
   def updateMessages(self, parameters):  
     """Modify the messages created by internal validation for each tool  
     parameter. This method is called after internal validation."""  
     return  
   def execute(self, parameters, messages):      
     reload(m_main_layer)       
     m_main_layer.main_on()  
     return            
Here the main Python script:
 # -*- coding: utf-8 -*-  
 """  
 Created on Fri Mar 20 09:11:37 2020  
 """  
 # -*- coding: utf-8 -*-  
 import arcpy  
 # mark start of query condition  
 # comments such as /* -- */ do not work with FGDB  
 # therefore we add a dummy condition as start marker  
 query_start_marker = "'A'='A'"  
 query_concat = " AND "  
 # max value might be different for each database system in use:  
 max_num_selected_features_per_layer = 999  
 def remove_filter_features(lyr):    
   if not lyr.isFeatureLayer:  
     return   
   desc = arcpy.Describe(lyr.name)      
   query = lyr.definitionQuery  
   start = query.find(query_start_marker)         
   if start >= 0:  
     query_front = query[:start]                 
     len_query_conact = len(query_concat)  
     if len(query_front) > len_query_conact and query_front[-len_query_conact:] == query_concat:  
       query_front = query_front[:-len_query_conact]              
     lyr.definitionQuery = query_front  
 def apply_filter_selected_features(lyr):    
   if not lyr.isFeatureLayer:  
     return                
   desc = arcpy.Describe(lyr.name)        
   if desc.FIDSet != '':                   
     fid_list = desc.FIDSet.split(";")  
     if len(fid_list) > max_num_selected_features_per_layer:  
       arcpy.AddMessage("Too many features selected ({0}), max: {1}.".format(len(fid_list),max_num_selected_features_per_layer))  
       return  
     query = ' {} NOT IN ({}) '.format(desc.OIDFieldName, ",".join(fid_list))      
     existing_query = lyr.definitionQuery  
     if existing_query:  
       query = existing_query + query_concat + query_start_marker+ ' AND ' + query  
     else:  
       query = query_start_marker + ' AND ' + query      
     lyr.definitionQuery = query      
     arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")  
 def main_off():          
   arcpy.AddMessage("hide selected features....")  
   mxd = arcpy.mapping.MapDocument("CURRENT")       
   df = arcpy.mapping.ListDataFrames(mxd)[0]    
   for l in arcpy.mapping.ListLayers(df):  
     apply_filter_selected_features(l)  
   arcpy.AddMessage("hide selected features....finished")  
 def main_on():  
   arcpy.AddMessage("display hidden features....")  
   mxd = arcpy.mapping.MapDocument("CURRENT")       
   df = arcpy.mapping.ListDataFrames(mxd)[0]    
   for l in arcpy.mapping.ListLayers(df):  
     remove_filter_features(l)  
   arcpy.RefreshActiveView()            
   arcpy.AddMessage("display hidden features....finished")  

Example:

select features...
...hidden...


...bringing them back to screen...










Thursday, 19 December 2019

ArcGISServer / WebOffice - Reprojecting WMS service

It seems neither ArcGISServer nor VertiGIS WebOffice allow reprojecting a WMS service. However, that is what we needed as the WMS service provider from across the border did not want to add support for another coordinate system (epgs:2056) to its service. 

First option we looked into was MapProxy . It's relatively easy to install and to get a basic sample up and running. But it seems integration into IIS is not straightforward. I didn't bother to invest more time investigating this option any further. Fortunately, GeoServer also supports reprojecting WMS services - and surprisingly it was very easy to install and to get it to work. 

As we use VertiGIS WebOffice we have already Tomcat running. GeoServer installation is basically downloading the right file (Web-Archive), unzipping it and copying the resulting WAR file in to Tomcats WebApp folder and finally restarting Tomcat. Second step is to set up the WMS service - again straightforward as GeoServer comes with an easy to use and self-explaining web-interface.


Map project in epsg:2056, WMS service provided in epsg:25832 but reprojected by GeoServer

Monday, 21 October 2019

Geonis form with SQL

I added the following SQL statement to a Geonis form

 <edit title="Objekt" width="150">  
 <select>  
 select name_nummer as name from u_ele_trasseeabschnitt where globalid = [REF_FEAT_GID]  
 union all  
 select name_nummer as name from u_ele_strangabschnitt where globalid = [REF_FEAT_GID]  
 union all  
 select name || ', ' || u_tplnr from ele_tragwerk where globalid = [REF_FEAT_GID]  
 union all  
 select name || ', ' || u_tplnr from ele_schacht where globalid = [REF_FEAT_GID]  
 </select>  
 </edit>       

but I didn't get any results. Turns out that one needs to use the CONCAT command instead:

 <edit title="Objekt" width="150">  
 <select>  
 select name_nummer from u_ele_trasseeabschnitt where globalid = [REF_FEAT_GID]  
 union all  
 select name_nummer from u_ele_strangabschnitt where globalid = [REF_FEAT_GID]  
 union all  
 select concat(name, concat(', ', u_tplnr)) as name_nummer from ele_tragwerk where globalid = [REF_FEAT_GID]  
 union all  
 select concat(name, concat(', ', u_tplnr)) as name_nummer from ele_schacht where globalid = [REF_FEAT_GID]                                     
 </select>  
 </edit>                 

Geonis 2017.0

Monday, 7 October 2019

Geonis Interlis Export - ORA-24550: signal received: Unhandled exception: Code=e0434352 Flags=1

When exporting Interlis/LK Map FME just stopped working. Log file didn't contain any further information about the cause.

I had done an export successfully earlier with a project from the test database. Using the production database FME crashed.

The only difference I noticed was that the test project used an owner-connection to Oracle, the production project a editor-connection.

To get more information about the cause of the issue I ran the FME workbench in Windows command line - that's where I got the more detailed error message:



I don't really know what the error message is about. But when I run the export using the owner-connection it finishes successfully.

ArcMap 10.5.1, Geonis 2017.0, FME 2016, Oracle 11.2

Friday, 4 October 2019

GEONIS DB UPDATE - Umlauts not importet correctly

To import german umlauts (and other special characters) correctly into Oracle using Geonis Db Update the following two requirements have to be fullfilled:

(1) first line of XML file needs to define correct encoding:
<?xml version="1.0" encoding="utf-8"?>

(2) XML file encoding itself needs to be UTF-8 BOM

















Geonis 2017