05-31-2019 02:53 AM - edited 05-31-2019 08:27 AM
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 !
Solved! Go to Solution.
06-03-2019 03:26 AM
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:
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:
and using the Validate method only.
HTH,
Stefano
07-11-2019 01:29 AM
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