Skip to content

Instantly share code, notes, and snippets.

@dwins
dwins / project.scala
Created January 18, 2011 15:51
project.scala
override def repositories = super.repositories ++ Set(
"fusesource.m2" at "http://repo.fusesource.com/nexus/content/repositories/public/"
)
override def libraryDependencies = super.libraryDependencies ++ Set(
"org.fusesource.scalate" % "scalate-core" % "1.3.2"
)
trait MyString {
def theString: String
}
case class AString(theString: String) extends MyString
case class IntAsString(theInt: Int) extends MyString {
def theString = theInt.toString
}
object MyString {
val file = new java.io.FileInputStream(args(0))
val inflater = new java.util.zip.InflaterInputStream(file)
val bytes = Iterator.continually(inflater.read) takeWhile(-1 !=)
bytes.foreach(System.out.write)
System.out.flush()
diff --git a/src/geoserver/catalog.py b/src/geoserver/catalog.py
index 8f5331e..4f0a2e5 100644
--- a/src/geoserver/catalog.py
+++ b/src/geoserver/catalog.py
@@ -56,6 +56,12 @@ class Catalog(object):
None,
self.http
))
+ orig_req = self.http.request
+ def wrapped_request(*args, **kwargs):
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>
@dwins
dwins / fixup_styles.py
Created November 19, 2010 14:16
Find layers using default styles and generate independent styles for each
#!/usr/bin/env python
from geoserver.catalog import Catalog
from itertools import cycle, izip
import re
_punc = re.compile(r"[\.:]") #regex for punctuation that confuses restconfig
_foregrounds = ["#ffbbbb", "#bbffbb", "#bbbbff", "#ffffbb", "#bbffff", "#ffbbff"]
_backgrounds = ["#880000", "#008800", "#000088", "#888800", "#008888", "#880088"]
@dwins
dwins / sh.py
Created November 3, 2010 13:51
run virtualenv-sandboxed commands from a python script running outside the venv
import os
def vexec(cmd):
os.system("source bin/activate && DJANGO_SETTINGS_MODULE=geonode.settings " + cmd)
* {
mark: url("http://example.com/example.jpg");
mark-size: [ATTR * 6];
}
import logging
for _module in ["geonode.maps.views"]:
_logger = logging.getLogger(_module)
_logger.addHandler(logging.FileHandler("geonode.log"))
_logger.setLevel(logging.DEBUG)
import org.geoscript._
import style_new._
import filter.Expression.enrichString
// import enrichString for spiffy "".cql method, otherwise strings are treated as literals
// alternatively: import org.geotools.filter.text.ecql.ECQL.{ toExpression => cql }
// to use cql("")
val states = layer.Shapefile("geoscript/src/test/resources/data/states.shp")
val theme =