-
Notifications
You must be signed in to change notification settings - Fork 3
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
dynamically finding crs nodes from xml if matching with preferred crs. if not but has nodes then take first available node from xml. if none apply take our first preferred crs #416
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ public class WmsGetCapabilities : BaseRequest, IGetCapabilities | |
{ | ||
public Uri GetCapabilitiesUri => Url; | ||
public const string DefaultFallbackVersion = "1.3.0"; | ||
private string[] preferredCRS = { "EPSG:28992", "EPSG:4326", "CRS:84" }; | ||
|
||
public ServiceType ServiceType => ServiceType.Wms; | ||
protected override Dictionary<string, string> defaultNameSpaces => new() | ||
|
@@ -184,13 +185,32 @@ public List<MapFilters> GetMaps(int width, int height, bool transparent) | |
// Extract styles for the layer | ||
var styles = ExtractStyles(mapNode); | ||
|
||
// CRS/SRS may be defined in the current MapNode, but can also inherit from a parent if it is not | ||
// specified the flag at the end of this function will check the current node and its parents | ||
var spatialReference = GetInnerTextForNode(mapNode, mapTemplate.spatialReferenceType, true); | ||
|
||
// TODO: Really ugly fix to deal issues around EPSG:4326. So we fixate on CRS:84 now, hoping that will | ||
// work in all situations | ||
spatialReference = "CRS:84"; | ||
string spatialReference = null; | ||
var spatialReferenceType = MapFilters.SpatialReferenceTypeFromVersion(new Version(mapTemplate.version)); | ||
XmlNodeList crsNodes = GetNodesByName(mapNode, spatialReferenceType); | ||
if (crsNodes.Count > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Als je dit in een methode plaatst dan kan dat leesbaarder en kan je het gebruik van GOTO vermijden omdat je op die plek een return kan doen. Tevens kan het nesting niveau omlaag door het gebruik van early return
|
||
{ | ||
for (int i = 0; i < preferredCRS.Length; i++) | ||
{ | ||
foreach (XmlNode crsNode in crsNodes) | ||
{ | ||
if (preferredCRS[i] == crsNode.InnerText) | ||
{ | ||
spatialReference = crsNode.InnerText; | ||
goto referenceFound; | ||
} | ||
} | ||
} | ||
if (string.IsNullOrEmpty(spatialReference)) | ||
{ | ||
spatialReference = crsNodes[0].InnerText; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dit geeft niet de eerste ondersteunde CRS terug maar de eerste in de set crsNodes, zie AC 3. Dit kan een ongeldige situatie opleveren |
||
} | ||
} | ||
if(string.IsNullOrEmpty(spatialReference)) | ||
{ | ||
spatialReference = preferredCRS[0]; | ||
} | ||
referenceFound: | ||
|
||
var map = new MapFilters() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overbodige code?