Polygon in XSLT transformation - geography data type

Hello,
I’ve a XSLT transformation with AS:HttpRequest, which returns XML a with a polygon data in one element like this:

 <ns2:GEOMETRIE>POLYGON ((-740614.4101 -1030989.305, -741540.4803 -1030921.8493, -741540.4149 -1030920.9517, -741542.3916 -1030936.2522, -741555.0577 -1031034.2896, -741583.5733 -1031255.006, -741589.2724 -1031299.1183, -741588.2768 -1031299.2164, -740960.9255 -1031344.9745, -740959.4536 -1031345.103, -740897.274 -1031297.208, -740851.0788 -1031262.415, -740803.977 -1031228.374, -740769.1989 -1031197.8036, -740738.9305 -1031169.0874, -740729.4307 -1031158, -740720.3038 -1031147.3563, -740682.2743 -1031090.7, -740643.6627 -1031028.611, -740623.6778 -1031000.671, -740614.4101 -1030989.305))</ns2:GEOMETRIE>
            

Is there any way I can pass this polygon value to attribute/element in correct format so it is saved in SQL database column with geography data type? I know there is an undocumented function AS:PointFromJtsk, which creates a point. Is there similar function for polygons?

No there’s no such function in our codebase.

@washi
Approximately how much would it cost to implement this feature?

The estimated effort is between 1-4 hours.

On the other hand it should be enough to take the string and store it in the geography column. It is supposed to work out of box. The format looks valid to me.

The input polygon coordinates are in JTSK format. So as a first step it is necessary to convert it to WGS-84 format. So it would be better to create XSL function PolygonFromJtsk - you can reuse Origam.Geo functions. There is a web, where you can test the conversion - https://martin.hinner.info/geo/.
When you insert this coordinates

-740614.4101 -1030989.305
-741540.4803 -1030921.8493
-741540.4149 -1030920.9517
-741542.3916 -1030936.2522
-741555.0577 -1031034.2896
-741583.5733 -1031255.006
-741589.2724 -1031299.1183
-741588.2768 -1031299.2164
-740960.9255 -1031344.9745
-740959.4536 -1031345.103
-740897.274 -1031297.208
-740851.0788 -1031262.415
-740803.977 -1031228.374
-740769.1989 -1031197.8036
-740738.9305 -1031169.0874
-740729.4307 -1031158
-740720.3038 -1031147.3563
-740682.2743 -1031090.7
-740643.6627 -1031028.611
-740623.6778 -1031000.671
-740614.4101 -1030989.305

you should see the following polygon on the map:

@washi Our customer agrees with the estimated effort to implement this feature. Please provide me with an estimated implementation date - we are actually in a time pressure from a customer.

Thank you.

This function would be available with 25.5 release, that should be available in the week starting from 5th of May. If this would be an issue, there is still possibility to create separate library that is not dependent on Origam release cycle. It would mean some extra overhead (1-4 hrs) and it wouldn’t be part of the main Origam relaease. It would also have more complicated deployment. You would need to deploy the extra dll and also the extra model package with the definition of the namespace.

Let’s do it standard way and wait for 25.5 release.

I’m confused by the output from S-JTSK->WGS84. After I input the coordinate pairs I get a table with six columns… How exactly should I map that to the polygon coordinates for the given example?

POLYGON ((-740614.4101 -1030989.305, -741540.4803 -1030921.8493, -741540.4149 -1030920.9517, -741542.3916 -1030936.2522, -741555.0577 -1031034.2896, -741583.5733 -1031255.006, -741589.2724 -1031299.1183, -741588.2768 -1031299.2164, -740960.9255 -1031344.9745, -740959.4536 -1031345.103, -740897.274 -1031297.208, -740851.0788 -1031262.415, -740803.977 -1031228.374, -740769.1989 -1031197.8036, -740738.9305 -1031169.0874, -740729.4307 -1031158, -740720.3038 -1031147.3563, -740682.2743 -1031090.7, -740643.6627 -1031028.611, -740623.6778 -1031000.671, -740614.4101 -1030989.305))

Thanks

The coordinate transformation can be verified here as well.

@washi Thank you! Could you please push it to the master, so we can test it?

@jsusen I tried the XSLT Function PolygonFromJstk in transformation in Architect 2025.5.0.3830, but I got error when I transformed it in Architect editor.

Cannot find a script or an extension object associated with namespace 'http://xsl.origam.com/geo'.
Transformation result invalid.

The testing transformation looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:AS="http://schema.advantages.cz/AsapFunctions"
	xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date"
	xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:vOKO="http://www.pds.eu/vOKO/v0200"
	xmlns:ns2="http://sitewell.cz/lpis/schemas/LPI_GDP01A"
	xmlns:GE="http://xsl.origam.com/geo"	
	>

	<xsl:template match="ROOT">
		<ROOT>
			<geometrie>
				<xsl:value-of select="GE:PolygonFromJstk('POLYGON ((-740614.4101 -1030989.305, -741540.4803 -1030921.8493, -741540.4149 -1030920.9517, -741542.3916 -1030936.2522, -741555.0577 -1031034.2896, -741583.5733 -1031255.006, -741589.2724 -1031299.1183, -741588.2768 -1031299.2164, -740960.9255 -1031344.9745, -740959.4536 -1031345.103, -740897.274 -1031297.208, -740851.0788 -1031262.415, -740803.977 -1031228.374, -740769.1989 -1031197.8036, -740738.9305 -1031169.0874, -740729.4307 -1031158, -740720.3038 -1031147.3563, -740682.2743 -1031090.7, -740643.6627 -1031028.611, -740623.6778 -1031000.671, -740614.4101 -1030989.305))')" />
			</geometrie>
		</ROOT>
	</xsl:template>

	
</xsl:stylesheet>

This is stack trace, when I try to run it on server.

2025-05-06 21:46:16,465 [25] ERROR Origam.Workflow.WorkflowEngine - Cannot find a script or an extension object associated with namespace 'http://xsl.origam.com/geo'.
Workflow stack trace
	Step: 'TestPolygon/Transform'

Origam.OrigamException: Cannot find a script or an extension object associated with namespace 'http://xsl.origam.com/geo'.
 ---> System.Exception: Cannot find a script or an extension object associated with namespace 'http://xsl.origam.com/geo'.
 ---> System.Exception: Transformation result invalid.
 ---> System.Xml.Xsl.XslTransformException: Cannot find a script or an extension object associated with namespace 'http://xsl.origam.com/geo'.
   at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
   at <xsl:template match="ROOT">(XmlQueryRuntime)
   at <xsl:apply-templates>(XmlQueryRuntime, XPathNavigator)
   at Root(XmlQueryRuntime)
   at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
   at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, Stream results)
   at Origam.Rule.Xslt.CompiledXsltEngine.Transform(Object engine, XsltArgumentList xslArg, XPathDocument sourceXpathDoc, IXmlContainer resultDoc) in D:\a\1\s\backend\Origam.Rule\Xslt\CompiledXsltEngine.cs:line 68
   at Origam.Rule.Xslt.MicrosoftXsltEngine.Transform(IXmlContainer data, Object xsltEngine, Hashtable parameters, String transactionId, IDataStructure outputStructure, Boolean validateOnly) in D:\a\1\s\backend\Origam.Rule\Xslt\MicrosoftXsltEngine.cs:line 175
   --- End of inner exception stack trace ---
   at Origam.Rule.Xslt.MicrosoftXsltEngine.Transform(IXmlContainer data, Object xsltEngine, Hashtable parameters, String transactionId, IDataStructure outputStructure, Boolean validateOnly) in D:\a\1\s\backend\Origam.Rule\Xslt\MicrosoftXsltEngine.cs:line 207
   --- End of inner exception stack trace ---
   at Origam.Rule.Xslt.MicrosoftXsltEngine.Transform(IXmlContainer data, Object xsltEngine, Hashtable parameters, String transactionId, IDataStructure outputStructure, Boolean validateOnly) in D:\a\1\s\backend\Origam.Rule\Xslt\MicrosoftXsltEngine.cs:line 234
   at Origam.Rule.Xslt.AbstractXsltEngine.Transform(IXmlContainer data, Guid transformationId, Guid retransformationId, Hashtable parameters, String transactionId, Hashtable retransformationParameters, IDataStructure outputStructure, Boolean validateOnly) in D:\a\1\s\backend\Origam.Rule\Xslt\AbstractXsltEngine.cs:line 163
   at Origam.Rule.Xslt.AbstractXsltEngine.Transform(IXmlContainer data, Guid transformationId, Hashtable parameters, String transactionId, IDataStructure outputStructure, Boolean validateOnly) in D:\a\1\s\backend\Origam.Rule\Xslt\AbstractXsltEngine.cs:line 127
   at Origam.Workflow.TransformationAgent.Run() in D:\a\1\s\backend\Origam.Workflow\Service Agents\TransformationAgent.cs:line 80
   at Origam.Workflow.Tasks.ServiceMethodCallEngineTask.OnExecute() in D:\a\1\s\backend\Origam.Workflow\Tasks\ServiceMethodCallEngineTask.cs:line 200
   at Origam.Workflow.ProfilingTools.<>c__DisplayClass4_0.<ExecuteAndLogDuration>g__FuncToExecute|0() in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 63
   at Origam.Workflow.ProfilingTools.ExecuteAndLogDuration(Func`1 funcToExecute, String logEntryType, String path, String id, Func`1 logOnlyIf) in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 97
   at Origam.Workflow.ProfilingTools.ExecuteAndLogDuration(Action action, String logEntryType, String path, String id, Func`1 logOnlyIf) in D:\a\1\s\backend\Origam.Workflow\ProfilingTools.cs:line 66
   at Origam.Workflow.Tasks.AbstractWorkflowEngineTask.MeasuredExecution() in D:\a\1\s\backend\Origam.Workflow\Tasks\AbstractWorkflowEngineTask.cs:line 99
   at Origam.Workflow.Tasks.ServiceMethodCallEngineTask.Execute() in D:\a\1\s\backend\Origam.Workflow\Tasks\ServiceMethodCallEngineTask.cs:line 66
   --- End of inner exception stack trace ---

Are you also using the newest model?

Yes. I updated the Root and Security package as well.