Hexagon Geospatial
MENU

GeoMedia

Search for an answer, post a question, or answer other users' questions in our GeoMedia support discussions. This discussion board is a great way to collaborate with industry peers around the world. It is intended for discussion and support of the GeoMedia Desktop and Add-on applications.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 61
Registered: ‎05-30-2016
Accepted Solution

Style Expression to Detect CompositePolygon

Is there a legend entry style expression that can detect if the Geometry field value is a CompositePolygon vs. a regular Polygon or a collection of regular polygons?

Regular Contributor
Posts: 185
Registered: ‎05-25-2016

Re: Style Expression to Detect CompositePolygon

No. The style of a legend entry is not related to a geometry field value, it's only related to the geometry type. The area style object doesn't vary between a CompositePolygon, a Polygon or a GeometryCollection with Polygons.

 

The exactly type of a geomtry field value, e.g. for a selected record, can only be determined by converting the blob value to an GeoMedia geometry object.

Staff
Posts: 190
Registered: ‎02-02-2016

Re: Style Expression to Detect CompositePolygon

[ Edited ]

Here are a couple of expressions that can be used from Style Properties that you may find useful.

 

To determine if the geometry of an area feature is of type GeometryCollection (i.e. a collection of regular PolygonGeometry components) you can use this expression....

 

IF (COUNT(GEOMETRIES(Input.Geometry)) >1, TRUE(), FALSE())

 

If you want to assign this expression to the Color property and assign a color of 'red' to features that are of type GeometryCollection, and assign a color of 'blue' to those features that are not collections, the expression would look like the following...

 

IF (COUNT(GEOMETRIES(Input.Geometry)) >1, RGB(255,0,0), RGB(0,0,255))

 

To determine if the geometry of an area feature instance is of type CompositePolygonGeometry requires a more complex expression and the results may not be definitive. However if the area feature was inserted via GeoMedia and it is of type CompositePolygonGeometry this will typically mean that it contains an ArcGeometry as one of the component geometries.  Therefore we can use an expression that compares the length of the perimeter of the original feature (with the arc included) and the length of the perimeter when calculated by Segments using the start point and end point of each segment to determine if the area feature contains an arc and is thereby a CompositePolygonGeometry.

 

Here is the expression to make that comparison and return a value of true if the feature contains an arc and is thus a CompositePolygonGeometry.

 

IF(SUM(LENGTH(CREATEPOLYLINE(STARTPOINT(SEGMENTS(Input.Geometry)), ENDPOINT(SEGMENTS(Input.Geometry))), ProjectedMeas, Meter)) <> PERIMETER (Input.Geometry, ProjectedMeas, Meter), TRUE(), FALSE())

 

If you want to assign this expression to the Color property and assign features that are of type CompositePolygonGeometry a color of 'red' and assign those features that are not composite a color of 'blue' the expression would look like the following...

 

IF(SUM(LENGTH(CREATEPOLYLINE(STARTPOINT(SEGMENTS(Input.Geometry)), ENDPOINT(SEGMENTS(Input.Geometry))), ProjectedMeas, Meter)) <> PERIMETER(Input.Geometry, ProjectedMeas, Meter), RGB(255,0,0), RGB(0,0,255))

 

You can modify these expressions for use with other style properties by replacing the TRUE() and FALSE() parameters of the expression with the appropriate values for the style property that you want to change based on the expression result.

 

 

 

Contributor
Posts: 61
Registered: ‎05-30-2016

Re: Style Expression to Detect CompositePolygon

Thanks for this fulsome and extensive answer, jmorris. Much appreciated.

 

Can you explain why the results "may not be definitive"? Is it because the CompositePolygon might not contain any arcs?

Highlighted
Staff
Posts: 190
Registered: ‎02-02-2016

Re: Style Expression to Detect CompositePolygon

In answer to your follow-up question.  Yes, one reason the result might not be definitive is that an ArcGeometry does not have to be a component of a CompositePolygonGeometry.  For instance if the data was created by an application other than GeoMedia, that application could have created features that are constructed in such a manner that they are served into GeoMedia as CompositePolygonGeometry even though they don't contain ArcGeometry.

 

Using the COMPRESS function to update the geometry in those cases can sometimes restructure the geometry to a simpler compressed form so that it is no longer defined as composite geometry.

 

Another case where the result might not be exactly what you had in mind occurs when an area feature contains a Hole. Specifically if the Hole is defined using an ArcGeometry then the Hole will be of type CompositePolygonGeometry, but the top level geometry will be defined as a BoundaryGeometry consisting of an Exterior and Hole component.  So in that case the expression would return a feature of type BoundaryGeometry that contains a component geometry (the Hole) that is of type CompositePolygonGeometry component.

Contributor
Posts: 61
Registered: ‎05-30-2016

Re: Style Expression to Detect CompositePolygon

Good point about the holes. I've actually been using a 0 sized buffer to convert them to either Polygon or a Collection of Polygons. I'm not sure how that handles holes. I'll have to check that.

Polls
Please register to vote
Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.