Skip to content

Instantly share code, notes, and snippets.

@dwins
Created December 16, 2010 15:14
Show Gist options
  • Save dwins/743506 to your computer and use it in GitHub Desktop.
Save dwins/743506 to your computer and use it in GitHub Desktop.
val orig = xml.XML.load("OSM_Roads.sld")
val ftypes = orig \\ "FeatureTypeStyle"
val printer = new xml.PrettyPrinter(80, 2)
for (name <- Seq("railway", "aeroway", "highway")) {
val nodes =
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
<UserStyle>
<FeatureTypeStyle>
{ ftypes.filter { _ \\ "Filter" \\ "PropertyName" forall(_.text == name) } flatMap (_ \\ "Rule") }
</FeatureTypeStyle>
</UserStyle>
</StyledLayerDescriptor>
val writer = new java.io.FileWriter(name + "s.sld")
writer.write(printer.format(nodes))
writer.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment