Skip to content

Instantly share code, notes, and snippets.

Ryan Clark rclark

  • Mapbox
  • Tucson, AZ
Block or report user

Report or block rclark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rclark
rclark / L.Composite.js
Last active May 30, 2019
Composite Leaflet Layer
View L.Composite.js
L.Composite = L.Class.extend({
includes: L.Mixin.Events,
initialize: function (options) {
// options should include:
// - tileUrl: A URL template for this layer's visible representation
// - tileOptions (optional): Any [config options for the L.TileLayer](http://leafletjs.com/reference.html#tilelayer-options)
// - geojsonUrl: A URL that retrieves GeoJSON data for this layer as a FeatureCollection,
// or a [Github blob API call](http://developer.github.com/v3/git/blobs/#get-a-blob)
// - geojsonOptions (optional): [Config options for the L.GeoJSON layer](http://leafletjs.com/reference.html#geojson-options)
View demo.js
// [Official documentation](https://github.com/mbostock/d3/wiki/Selections)
// Some "data". These might be "models" in your app.
// D3 always wants an array of data, since no one likes
// to say "datum".
var data = [
{
id: "first",
name: "This is the First",
description: "This is a description of the first.",
@rclark
rclark / schema.js
Last active Dec 23, 2015
Extendable Project Open Data Metadata JSON-Schema : http://project-open-data.github.io/schema/
View schema.js
var _ = require('underscore');
module.exports = function (additionals, overrides) {
additionals = _.isArray(additionals) ? additionals : [];
overrides = _.isObject(overrides) ? overrides : {};
function conditional (field) {
return _.contains(additionals, field);
}
View metadata.json
{
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"geometry": {
"type": "polygon",
"coordinates": [
@rclark
rclark / email-that-isnt-spam
Created Sep 18, 2013
Thoughts for Christoph and Raj
View email-that-isnt-spam
You've got 1M points in your system. Here are the places where that's going to bottleneck you:
- Asking Geoserver for WMS or WFS results is going to mean pulling those 1M points from the database and then running them through a pipeline that results in either a) a large XML document (WFS) or b) an image (WMS). In both cases, query results will be held in memory on the server until the processing is complete.
- There is probably much less processing involved in building the XML doc than there is to render the image. However, the next step in the process is sending the result to the client. The XML doc will be huge (either in the "shortened" content model form, or the enormous flat form you mention). It will take forever to get across the wire, and you'll probably start timing out in various parts of the pipeline.
- The data arrives at the client's web browser. In the case of the WMS request, you're fine, because its a little file and a minimal amount of processing required to draw that image on the map. In
View make-the-connection.js
function mblConnect() {
var $cont = $('#connect'),
$site = $('#site'),
isOpen = false,
$overlay = $('<div id="mbl-overlay" class="mbl-overlay js-connect-btn" />'),
dropdown = {
enable: function () {
var $btns = getBtns();
$btns.off().on('click', clicked);
View option1.js
function MyThing() {
var theThing = new Thing();
theThing.privateMethod();
return theThing;
}
// Somewhere else...
var whatIWant = MyThing();
@rclark
rclark / segment-page.js
Created Sep 17, 2013
class / function pattern for chaining
View segment-page.js
trailguide.models.segment('segment-2').fetch({
success: function(segment, response, xhr) {
var butt = new trailguide.views.details({
model: segment,
el: '#details'
});
butt.render();
}
});
@rclark
rclark / what-spatial-gives.json
Created Sep 13, 2013
what the ckanext-spatial csw_harvester gives you
View what-spatial-gives.json
{
"name": "missouri-rock-chemistry",
"title": "Missouri Rock Chemistry",
"notes": "This is a collection of rock chemistry observations compiled by the Missouri Geological Survey and published as a Web feature service, a web map service, an ESRI service and as an Excel spreadsheet for the National Geothermal Data System by the AZGS. The document contains 12 worksheets including resource provider information and the data, which is documented in Whole Rock Major Element, U-Series, Isotope Series, Rare Earth, Volatile Gas and Noble Gas analyte suites. Data from a total of 2613 wells are included.",
"tags": [
{
"name": "Whole Rock Chemisty Analysis"
},
{
"name": "Geothermal"
@rclark
rclark / ngds-ckan-pacakge.json
Last active Dec 23, 2015
An NGDS-styled CKAN Package
View ngds-ckan-pacakge.json
{
"id": "12340kjfha1092412",
"metadata_modified": "2013-09-13T20:35:03.757357",
"metadata_created": "2013-09-12T20:35:03.757357",
"title": "Whatever the title is",
"notes": "The abstract / description of this thing",
You can’t perform that action at this time.