Skip to content
This repository has been archived by the owner on Sep 3, 2019. It is now read-only.

NullReferenceException with simple MapCss #259

Open
aafloy opened this issue Jul 24, 2015 · 0 comments
Open

NullReferenceException with simple MapCss #259

aafloy opened this issue Jul 24, 2015 · 0 comments

Comments

@aafloy
Copy link

aafloy commented Jul 24, 2015

I'm trying to construct my own mapcss file, and I'm having problems with loading this with OsmSharp. The parsing itself is fine (since I get a cssfile from the code below), but the interpreter is returning a NullReferenceException (se below). I've worked around this issue by removing the generic way css clause, but this should work fine though?

Example code:

var cssfile = OsmSharp.UI.Map.Styles.MapCSS.v0_2.Domain.MapCSSFile.FromString(mapcss);
var geometryInterpreter = new OsmSharp.Osm.Interpreter.SimpleGeometryInterpreter();
var interpreter = new OsmSharp.UI.Map.Styles.MapCSS.MapCSSInterpreter(cssfile,
                new OsmSharp.UI.Map.Styles.MapCSS.MapCSSDictionaryImageSource(), geometryInterpreter);

MapCss file:

canvas {
  background-color: white;
  default-points: false;
  default-lines: false;
}

way {
    color: black;
    width: 1;
}

way[highway=motorway] {
    color: orange; 
}

Exception stack trace for the NullReferenceException:

 at OsmSharp.UI.Map.Styles.MapCSS.v0_2.Domain.SelectorRuleTagValueComparison.AddRelevantKeysTo(ICollection`1 relevantKeys)
   at OsmSharp.UI.Map.Styles.MapCSS.MapCSSInterpreter.PrepareForProcessing()
   at OsmSharp.UI.Map.Styles.MapCSS.MapCSSInterpreter..ctor(MapCSSFile mapCSSFile, IMapCSSImageSource imageSource, GeometryInterpreter geometryInterpreter)
   at RenderTest.Form1..ctor() in K:\Testing\RenderTest\RenderTest\Form1.cs:line 80
   at RenderTest.Program.Main() in K:\Testing\RenderTest\RenderTest\Program.cs:line 21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant