Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add srsName to GML3 (optional) and all GML2 #575

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ArneD
Copy link

@ArneD ArneD commented Dec 10, 2021

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository.
  • I have provided test coverage for my change (where applicable)

Description

Before I continue with the rest of the tests I would like your input to see if this could be approved.

This PR contains 2 changes to the GML writers.

  1. In our use case we would like to have the GML3 writer output the srsName attribute.
  2. Based on a previous PR I saw that Point, LinearString, LinearRing, Polygon didn't output the srsName while it looks required to me: http://schemas.opengis.net/gml/2.1.2/geometry.xsd .
    XSD isn't my strong suit, so might be mistaken. It looks like only members of the MultiPolygon for example are optional.

Possible improvements:
Add new ctor for GML3Writer that would take a pattern as input for example https://www.opengis.net/def/crs/EPSG/0/{0}.
This would be vulnerable to injection so would have to check if it's a urn or URI.
Though this could be easily done by creating your own GML writer and inheriting from GML3Writer and overriding GetSrsName.

@CLAassistant
Copy link

CLAassistant commented Dec 10, 2021

CLA assistant check
All committers have signed the CLA.

[Test]
public void TestGML3Point()
{
var document = ToGML3(CreatePoint());
var geometry = CreatePoint();
var document = ToGML3(geometry);
AssertPoint(document);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this?

Copy link
Member

@FObermaier FObermaier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition, please see comments

@@ -23,6 +22,8 @@ public class GMLWriter
private const int CoordSize = 200;
private readonly GMLVersion _gmlVersion;
private readonly string _gmlNs;
private readonly string _gmlSrsName = "srsName";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private const string GmlSrsName = "srsName";

protected virtual void WriteAttributeSrsName(int srid, XmlWriter xmlWriter)
{
if(_writeSrsNameAttribute)
xmlWriter.WriteAttributeString(_gmlSrsName, GetSrsName(srid));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xmlWriter.WriteAttributeString(GmlSrsName, GetSrsName(srid));

@@ -103,7 +106,7 @@ private static XDocument ToGML3(Geometry geom)
using var ms = new MemoryStream();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change signature to
private static XDocument ToGML3(Geometry geom, bool writeSrsName = true)

Duplicate at least one of the actual tests where writeSrsName is set to false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants