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
Contributor
Posts: 56
Registered: ‎02-19-2019
Accepted Solution

Polygon must contain the point

[ Edited ]

Hi community,

 

I have a planning application using M.App Enterprise 2018 version. One point could have multiple polygon and user can create multiple polygon associated with point ID . I need to put validation that one polygon must contain the point (Fig 2). Please see the below image file that Fig 1 is not valid beacause polygon not cotain the point. Fig 2 is valid because one polygon contain the point.  

 

I need to show message to user if polygon not contain point and user can't save polygong . How can I achieved this task ? 

Thanks in advance !

 

Polygon validation.png

Staff
Posts: 1,051
Registered: ‎10-18-2015

Re: Polygon must contain the point

hi Liton,

 

you have to apply a geometry validation handler on the server side (implementing IGeometryValidationHandler in a class library and copying it to bin directory of workflows). Please have a look at the GMSC documentation, the implementation is  mostly the same:

 

https://community.hexagongeospatial.com/t5/Developers-Knowledge-Base/GMSC-Developer-s-Guide/ta-p/153...

 

in the doc there is an example:

https://hgdsupport.hexagongeospatial.com/API/GMSC/Server/index.html#topic_00000000000013ED.html

 

In the case of M.App Enterprise you have to reference the following libraries:

  • MApp Core
  • MApp Workflows

and using the Validate method only. 

 

HTH,

Stefano

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Contributor
Posts: 56
Registered: ‎02-19-2019

Re: Polygon must contain the point

Hi Stefano,

 

I have resolved this issue through store procedure.  Please see my storedProcedure, this is executing after trigger. where I'm getting point and polygong geometry and checking point is in polygon or not (STIntersects). Then showing the message to user. 

USE [MAPP_APPLICATION_PLAN]
GO
/****** Object:  StoredProcedure [dbo].[getValidationStatus]    Script Date: 10/07/2019 16:22:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[getValidationStatus] @PD_ID int
as
begin
	DECLARE @PP_PK int
	SET @PP_PK = (SELECT PP_PK FROM PLANNING_DATA WHERE PD_ID = @PD_ID)

	if ((select COUNT(*) from PLANNING_DATA where PP_PK = @PP_PK) < 2)
	begin
		DECLARE @Site geometry
		DECLARE @Point geometry
		set @Site = (select a.Geometry_SPA 'Site GEOM' from PLANNING_DATA a inner join PLANNING_POINT b on b.PP_PK = @PP_PK where PD_ID = @PD_ID);
		set @Point = (select b.Geometry_SPA 'Point GEOM' from PLANNING_DATA a inner join PLANNING_POINT b on b.PP_PK = @PP_PK where PD_ID = @PD_ID);

		if (@Point.STIntersects(@Site) = 0)
		begin
			exec validationFailed @PD_ID
			select 'Geometry Invalid! This site needs to be contain the Planning Application point'
		end
		--exec validationPassed @PD_ID
		else select 'Geometry Successfully Saved.'
	end
	else select 'Geometry Successfully Saved.'
end

 If validation is failed then using thie procedure.

 

USE [MAPP_APPLICATION_PLAN]
GO
/****** Object:  StoredProcedure [dbo].[validationFailed]    Script Date: 11/07/2019 09:27:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[validationFailed] @PD_ID int
as
begin
	delete from PLANNING_DATA where PD_ID = @PD_ID
end