Skip to content

Instantly share code, notes, and snippets.

@dwins
dwins / fetch.sh
Created September 22, 2011 22:40
MN2GT Support Scripts
wget \
http://developer.mapquest.com/content/static/geotiffs/mercator_tiffs.tar \
http://tile.openstreetmap.org/world_boundaries-spherical.tgz \
http://tile.openstreetmap.org/processed_p.tar.bz2 \
http://tile.openstreetmap.org/shoreline_300.tar.bz2
import org.geoscript._
import layer.Shapefile, support.math.Interpolation, style.combinators._,
style.io.SLD, io.Sink
import org.geotools.filter.text.ecql.ECQL.{ toFilter => cql }
import java.awt.Color
val states = Shapefile("geoscript/src/test/resources/data/states.shp")
val buckets =
(states.features.map(_.get[Double]("PERSONS")).toSeq
@dwins
dwins / fonts.js
Created October 13, 2011 19:38
What fonts can Java find which are able to render Chinese text?
// Run with 'jrunscript fonts.js' or just copy/paste in the jrunscript interactive interpreter
var GraphicsEnvironment = Packages.java.awt.GraphicsEnvironment;
var fonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
var test = "\u4e00"; // a String, you can replace it with your own test text if you care about a different language.
// this value came from http://www.chinesecomputing.com/programming/java.html regarding Chinese text handling in Java
for (var i = 0; i < fonts.length; i++)
/** Represents a value of one of two possible types (a disjoint union.)
* Instances of Either are either an instance of [[scala.Left]] or [[scala.Right]].
*
* A common use of Either is as an alternative to [[scala.Option]] for dealing
* with possible missing values. In this usage, [[scala.None]] is replaced
* with a [[scala.Left]] which can contain useful information.
* [[scala.Right]] takes the place of [[scala.Some]]. Convention dictates
* that Left is used for failure and Right is used for success.
*
* For example, you could use ``Either[Exception, Int]`` to safely parse a String:
<?xml version="1.0"?>
<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.1.0" maxFeatures="100" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<wfs:Query xmlns:feature="http://geonode.org" typeName="feature:conflicts" srsName="EPSG:900913">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsBetween>
<ogc:PropertyName>EpEndDate</ogc:PropertyName>
<ogc:LowerBoundary>
<ogc:Literal>1946-07-21T04:00:00.000Z</ogc:Literal>
</ogc:LowerBoundary>
import org.apache.commons
@dwins
dwins / switch-on-env.sld.xml
Created December 29, 2011 18:55
Switch off rules in GeoServer styles based on query parameters
<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns="http://www.opengis.net/sld"
xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml">
<sld:Name>Default Styler</sld:Name>
<sld:Title/>
<sld:FeatureTypeStyle>
<sld:Name>name</sld:Name>
<sld:Rule>
<ogc:Filter>
trait Request
class RequestVerbs(req: Request) {
def <:< (headers: Map[String, String]): Request
}
implicit def requestsForVerbs(req: Request): RequestVerbs =
new RequestVerbs(req)
def url(theUrl: String): Request
@dwins
dwins / gist:1790448
Created February 10, 2012 15:56
Pylint rc file to identify functions, classes, and modules without docstrings
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.
@dwins
dwins / raster.css
Created April 12, 2012 18:23
Raster properties in CSS
* {
raster-opacity: 0.7;
raster-channel-selection: 1;
raster-channel-selection: 1 2 3;
raster-contrast-enhancement: normalize;
raster-contrast-enhancement: histogram;
raster-contrast-enhancement: gamma-value(2);
raster-shaded-relief: brightness-only;
raster-shaded-relief: relief-factor(55);
raster-shaded-relief: brightness-only relief-factor(55);