Adds the optional GeoJSON properties crs and bbox if they have been specified
341399
function addOptionals(geojson, settings){
    if(settings.crs && checkCRS(settings.crs)) {
      if(settings.isPostgres)
        geojson.geometry.crs = settings.crs;
      else
        geojson.crs = settings.crs;
    }
    if (settings.bbox) {
      geojson.bbox = settings.bbox;
    }
    if (settings.extraGlobal) {
      geojson.properties = {};
      for (var key in settings.extraGlobal) {
        geojson.properties[key] = settings.extraGlobal[key];
      }
    }
  }
511354
def add_properties_callbacks(cls):
    """"""
    for name in cls._mutators:                                                 #pylint: disable=protected-access
        if not hasattr(cls, name):
            continue
        setattr(cls, name, properties_mutator(cls, name))
    for name in cls._operators:                                                #pylint: disable=protected-access
        if not hasattr(cls, name):
            continue
        setattr(cls, name, properties_operator(cls, name))
    for name in cls._ioperators:                                               #pylint: disable=protected-access
        if not hasattr(cls, name):
            continue
        setattr(cls, name, properties_mutator(cls, name, True))
    return cls
901178
private void setJsonSchemaProperties(JsonObject jsonObject) {
    setColumnName(jsonObject.get(COLUMN_NAME_KEY).getAsString());
    setDataType(jsonObject.get(DATA_TYPE_KEY).getAsJsonObject());
    setNullable(jsonObject.has(IS_NULLABLE_KEY) && jsonObject.get(IS_NULLABLE_KEY).getAsBoolean());
    setComment(getOptionalProperty(jsonObject, COMMENT_KEY));
    setDefaultValue(getOptionalProperty(jsonObject, DEFAULT_VALUE_KEY));
  }
1304865
function mapOptions() {
          return {
            element: element[0],
            scope: 'usa',
            height: scope.height,
            width: scope.width,
            fills: { defaultFill: '#b9b9b9' },
            data: {},
            done: function (datamap) {
              function redraw() {
                datamap.svg.selectAll('g').attr('transform', 'translate(' + d3.event.translate + ')scale(' + d3.event.scale + ')');
              }
              if (angular.isDefined(attrs.onClick)) {
                datamap.svg.selectAll('.datamaps-subunit').on('click', function (geography) {
                  scope.onClick()(geography);
                });
              }
              if (angular.isDefined(attrs.zoomable)) {
                datamap.svg.call(d3.behavior.zoom().on('zoom', redraw));
              }
            }
          };
        }
113065
function checkObj(instance,objTypeDef,path,additionalProp){

         if(typeof objTypeDef =='object'){
             if(typeof instance != 'object' || instance instanceof Array){
                 errors.push({property:path,message:"an object is required"});
             }

             for(var i in objTypeDef){
                 if(objTypeDef.hasOwnProperty(i)){
                     var value = instance[i];
                     // skip _not_ specified properties
                     if (value === undefined && options.existingOnly) continue;
                     var propDef = objTypeDef[i];
                     // set default
                     if(value === undefined && propDef["default"]){
                         value = instance[i] = propDef["default"];
                     }
                     if(options.coerce && i in instance){
                         value = instance[i] = options.coerce(value, propDef);
                     }
                     checkProp(value,propDef,path,i);
                 }
             }
         }
         for(i in instance){
             if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_')
                 && objTypeDef && !objTypeDef[i] && additionalProp===false){
                 if (options.filter) {
                     delete instance[i];
                     continue;
                 } else {
                     errors.push({property:path,message:(typeof value) + "The property " + i +
                         " is not defined in the schema and the schema does not allow additional properties"});
                 }
             }
             var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
             if(requires && !(requires in instance)){
                 errors.push({property:path,message:"the presence of the property " + i + " requires that " +
                   requires + " also be present"});
             }
             value = instance[i];
             if(additionalProp && (!(objTypeDef && typeof objTypeDef == 'object') || !(i in objTypeDef))){
                 if(options.coerce){
                     value = instance[i] = options.coerce(value, additionalProp);
                 }
                 checkProp(value,additionalProp,path,i);
             }
             if(!_changing && value && value.$schema){
                 errors = errors.concat(checkProp(value,value.$schema,path,i));
             }
         }
         return errors;
       }
702543
function(key, options, callback){
    var self = this;
    //var layer = 0;
    var error = false,
      totalLayers,
      queryOpts = {}, 
      allLayers = [];

    // closure to check each layer and send back when done
    var collect = function(err, data){
      if (err) error = err;
      allLayers.push(data);
      if (allLayers.length == totalLayers){
        callback(error, allLayers);
      }
    };
        
    this._query('select info from "'+this.infoTable+'" where id=\''+(key+':'+(options.layer || 0 )+":info")+'\'', function(err, result){
      if ( err || !result || !result.rows || !result.rows.length ){
        callback('Not Found', []);
      } else if (result.rows[0].info.status == 'processing' && !options.bypassProcessing ) {
        callback( null, [{ status: 'processing' }]);
      } else {
          var info = result.rows[0].info;
          var select;
          if (options.simplify){
            select = 'select id, feature->>\'properties\' as props, st_asgeojson(st_simplifypreservetopology(geom::geometry, '+options.simplify+')) as geom from "' + key+':'+(options.layer || 0)+'"'; 
          } else {
            select = 'select id, feature->>\'properties\' as props, feature->>\'geometry\' as geom from "' + key+':'+(options.layer || 0)+'"'; 
          }
  
          // parse the where clause 
          if ( options.where ) { 
            if ( options.where != '1=1'){
              var clause = self.createWhereFromSql(options.where);
              select += ' WHERE ' + clause;
            } else {
              select += ' WHERE ' + options.where;
            }
          }

          // parse the geometry param from GeoServices REST
          if ( options.geometry ){
            var geom = self.parseGeometry( options.geometry );

            if (geom.xmin && geom.ymin ){
              var box = geom;
              if (box.spatialReference.wkid != 4326){
                var mins = merc.inverse( [box.xmin, box.ymin] ),
                  maxs = merc.inverse( [box.xmax, box.ymax] );
                box.xmin = mins[0];
                box.ymin = mins[1];
                box.xmax = maxs[0];
                box.ymax = maxs[1];
              }

              select += (options.where ) ? ' AND ' : ' WHERE ';
              var bbox = box.xmin+' '+box.ymin+','+box.xmax+' '+box.ymax;
              select += 'ST_GeomFromGeoJSON(feature->>\'geometry\') && ST_SetSRID(\'BOX3D('+bbox+')\'::box3d,4326)';
              //select += 'ST_Intersects(ST_GeomFromGeoJSON(feature->>\'geometry\'), ST_MakeEnvelope('+box.xmin+','+box.ymin+','+box.xmax+','+box.ymax+'))';
            }
          }

          self._query( select.replace(/ id, feature->>'properties' as props, feature->>'geometry' as geom /, ' count(*) as count '), function(err, result){
            if (!options.limit && !err && result.rows.length && result.rows[0].count > self.limit ){
              callback( null, [{
                exceeds_limit: true,
                type: 'FeatureCollection',
                features: [{}],
                name: info.name,
                sha: info.sha,
                info: info.info,
                updated_at: info.updated_at
              }]);

            } else {
              // ensure id order 
              select += " ORDER BY id";
              if ( options.limit ) {
                select += ' LIMIT ' + options.limit;
              }
              if ( options.offset ) {
                select += ' OFFSET ' + options.offset;
              }
              self.log.debug('Selecting data', select);
              self._query( select, function (err, result) {
                if ( result && result.rows && result.rows.length ) {
                  var features = [],
                    feature;
                  result.rows.forEach(function(row, i){
                    features.push({
                      "type": "Feature",
                      "id": row.id,
                      "geometry": JSON.parse(row.geom),
                      "properties": JSON.parse(row.props)
                    });
                  });
                  callback( null, [{
                    type: 'FeatureCollection', 
                    features: features, //_.pluck(result.rows, 'feature'),
                    name: info.name, 
                    sha: info.sha, 
                    info: info.info, 
                    updated_at: info.updated_at 
                  }]);
                } else {
                  callback( 'Not Found', [{
                    type: 'FeatureCollection',
                    features: []
                  }]);
                }
              });
            }
          });
        }
    });
  }
657156
private static JsonObjectBuilder addProperties( JsonObjectBuilder builder, VarValueDef value)
    {
    JsonArrayBuilder properties = Json.createArrayBuilder();
    value.getProperties().forEach( property -> properties.add( property));
    JsonArray json = properties.build();

    if( !json.isEmpty())
      {
      builder.add( PROPERTIES_KEY, json);
      }

    return builder;
    }
558825
function(object) {
       var proj = object.layer.projection.toString();
       var crs = {};
       if (proj.match(/epsg:/i)) {
           var code = parseInt(proj.substring(proj.indexOf(":") + 1));
           if (code == 4326) {
               crs = {
                   "type": "name",
                   "properties": {
                       "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
                   }
               };
           } else {    
               crs = {
                   "type": "name",
                   "properties": {
                       "name": "EPSG:" + code
                   }
               };
           }    
       }
       return crs;
    }
296572
def DictToAdditionalPropertyMessage(properties, additional_property_type,
                                    sort_items=False):
    """"""
    items = properties.items()
    if sort_items:
        items = sorted(items)
    map_ = []
    for key, value in items:
        map_.append(additional_property_type.AdditionalProperty(
            key=key, value=value))
    return additional_property_type(additionalProperties=map_)
691933
function GeoComplete(input, options) {

    this.options = $.extend(true, {}, defaults, options);

    // This is a fix to allow types:[] not to be overridden by defaults
    // so search results includes everything
    if (options && options.types) {
      this.options.types = options.types;
    }

    this.input = input;
    this.$input = $(input);

    this._defaults = defaults;
    this._name = 'geocomplete';

    this.init();
  }
985609
private static Optional<ICondition> asNotMoreThan( JsonObject json)
    {
    return
      Optional.of( json)
      .filter( j -> j.containsKey( NOT_MORE_THAN_KEY))
      .map( j -> j.getJsonObject( NOT_MORE_THAN_KEY))
      .map( a -> new AssertNotMore( a.getString( PROPERTY_KEY), a.getInt( MAX_KEY)));
    }
1233998
def geojson(self, feature_id):
        """"""
        lat, lon = self.lat_lon
        return {
            'type': 'Feature',
            'id': feature_id,
            'geometry': {
                'type': 'Point',
                'coordinates': (lon, lat),
            },
        }
308557
function( key, geojson, layerId, callback ){
    var self = this; 
    var info = {},
      count = 0;
      error = null;
      
      info.name = geojson.name ;
      info.updated_at = geojson.updated_at;
      info.expires_at = geojson.expires_at;
      info.retrieved_at = geojson.retrieved_at;
      info.status = geojson.status;
      info.format = geojson.format;
      info.sha = geojson.sha;
      info.info = geojson.info;
   
      var table = key+':'+layerId;

      var feature = (geojson[0]) ? geojson[0].features[0] : geojson.features[0];
      
      var types = {
        'esriGeometryPolyline': 'LineString',
        'esriGeometryPoint': 'Point',
        'esriGeometryPolygon': 'Polygon'
      };

      if (!feature){
        feature = { geometry: { type: geojson.geomType || types[geojson.info.geometryType] } };
      }

      self._createTable( table, self._buildSchemaFromFeature(feature), true, function(err, result){
        if (err){
          callback(err, false);
          return;
        }

        // insert each feature
        if ( geojson.length ){
          geojson = geojson[0];
        }
        geojson.features.forEach(function(feature, i){
          self._query(self._insertFeature(table, feature, i), function(err){ 
            if (err) {
              self.log.error(err); 
            }
          });
        });

        // TODO Why not use an update query here? 
        self._query( 'delete from "'+self.infoTable+'" where id=\''+table+':info\'', function(err,res){
          self._query( 'insert into "'+self.infoTable+'" values (\''+table+':info\',\''+JSON.stringify(info).replace(/'/g,'')+'\')', function(err, result){
            callback(err, true);
          });
        });
      });     
    
  }
780639
def render(self, **kwargs):
        """"""
        if isinstance(self._parent, GeoJson):
            keys = tuple(self._parent.data['features'][0]['properties'].keys())
            self.warn_for_geometry_collections()
        elif isinstance(self._parent, TopoJson):
            obj_name = self._parent.object_path.split('.')[-1]
            keys = tuple(self._parent.data['objects'][obj_name][
                             'geometries'][0]['properties'].keys())
        else:
            raise TypeError('You cannot add a GeoJsonTooltip to anything else '
                            'than a GeoJson or TopoJson object.')
        keys = tuple(x for x in keys if x not in ('style', 'highlight'))
        for value in self.fields:
            assert value in keys, ('The field {} is not available in the data. '
                                   'Choose from: {}.'.format(value, keys))
        super(GeoJsonTooltip, self).render(**kwargs)
1313687
function validateProperty(object, value, property, schema, options, errors, indexInArray, array) {
    var valid,
        type;

    function constrain(name, value, assert) {
      if (schema[name] !== undefined && !assert(value, schema[name])) {
        error(name, property, value, schema, errors);
      }
    }

    //validate default value
    if (options.validateDefaultValue && schema['default'] !== undefined &&
        property != 'default') {
      validateProperty(schema, schema['default'], 'default', schema, options, errors);
    }

    if (value === undefined) {
      //apply default value if have an option and default value
      if (options.applyDefaultValue && schema['default'] !== undefined) {
        value = schema['default'];
        object[property] = value;
        return;
      } else if (schema.required) {
        var required = schema.required;
        if (typeof required === 'function') {
          required = required(object, property);
        }
        if (required && schema.type !== 'any') {
          return error('required', property, undefined, schema, errors);
        } else {
          return;
        }
      } else {
        return;
      }
    }

    if (options.cast) {
      if (('integer' === schema.type || 'number' === schema.type) && value == +value) {
        value = +value;
      }

      if ('boolean' === schema.type) {
        if ('true' === value || '1' === value || 1 === value) {
          value = true;
        }

        if ('false' === value || '0' === value || 0 === value) {
          value = false;
        }
      }

      if ('date' === schema.type) {
        value = new Date(value);
      }
      //modify source object if we have an option and values are differ
      //for simple value
      if (options.castSource && indexInArray == null && object[property] !== value) {
        object[property] = value;
      } else
        if (options.castSource && indexInArray != null && array[indexInArray] !== value) {
          //and for an array
          array[indexInArray] = value;
        }
    }

    if (schema['enum'] && schema['enum'].indexOf(value) === -1) {
      error('enum', property, value, schema, errors);
    }

    // Dependencies (see 5.8)
    if (typeof schema.dependencies === 'string' &&
        object[schema.dependencies] === undefined) {
      error('dependencies', property, null, schema, errors);
    }

    if (isArray(schema.dependencies)) {
      for (var i = 0, l = schema.dependencies.length; i < l; i++) {
        if (object[schema.dependencies[i]] === undefined) {
          error('dependencies', property, null, schema, errors);
        }
      }
    }

    if (typeof schema.dependencies === 'object') {
      var oldAdditionalProperties = options.additionalProperties;
      options.additionalProperties = true;
      validateObject(object, schema.dependencies, options, errors);
      options.additionalProperties = oldAdditionalProperties;
    }

    checkType(value, schema.type, function(err, type) {
      var errorsCountBeforeCheckType = errors.length;
      if (err) return error('type', property, typeof value, schema, errors);

      constrain('conform', value, function (a, e) { return e(a, object, property) });

      switch (type || (isArray(value) ? 'array' : typeof value)) {
        case 'string':
          constrain('minLength', value.length, function (a, e) { return a >= e });
          constrain('maxLength', value.length, function (a, e) { return a <= e });
          constrain('pattern',   value,        function (a, e) {
            e = typeof e === 'string'
              ? e = new RegExp(e)
              : e;
            return e.test(a)
          });
          if (options.validateFormats) {
            constrain('format', value, function(value, format) {
              var spec;
              if (options.validateFormatExtensions) {
                spec = validate.formatExtensions[format];
              }
              if (!spec) {
                spec = validate.formats[format];
              }
              if (spec) {
                return spec.test(value);
              } else {
                return !options.validateFormatsStrict;
              }
            });
          }
          break;
        case 'integer':
        case 'number':
          constrain('minimum',     value, function (a, e) { return a >= e });
          constrain('maximum',     value, function (a, e) { return a <= e });
          constrain('exclusiveMinimum', value, function (a, e) { return a > e });
          constrain('exclusiveMaximum', value, function (a, e) { return a < e });
          constrain('divisibleBy', value, function (a, e) {
            var multiplier = Math.max((a - Math.floor(a)).toString().length - 2, (e - Math.floor(e)).toString().length - 2);
            multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;
            return (a * multiplier) % (e * multiplier) === 0
          });
          break;
        case 'array':
          constrain('items', value, function (a, e) {
            for (var i = 0, l = a.length; i < l; i++) {
              validateProperty(object, a[i], property, e, options, errors, i, a);
            }
            return true;
          });
          constrain('minItems', value, function (a, e) { return a.length >= e });
          constrain('maxItems', value, function (a, e) { return a.length <= e });
          constrain('uniqueItems', value, function (a) {
            var h = {};

            for (var i = 0, l = a.length; i < l; i++) {
              var key = JSON.stringify(a[i]);
              if (h[key]) return false;
              h[key] = true;
            }

            return true;
          });
          break;
        case 'object':
          // Recursive validation
          if (schema.properties || schema.patternProperties || schema.additionalProperties) {
            validateObject(value, schema, options, errors);
          }
          break;
      }

      //schema filtering
      if (schema.filter && errorsCountBeforeCheckType == errors.length) {
        if (type != 'array' && type != 'object') {
          var filters = isArray(schema.filter) ? schema.filter : [schema.filter];
          for (var i = 0, l = filters.length; i < l; i++) {
            var filter = null;
            if (isString(filters[i])) {
              if (filters[i] in validate.filters) {
                filter = validate.filters[filters[i]];
              } else {
                return error('filter', property, filters[i], schema, errors, 'unknown filter: %{actual}');
              }
            } else if (isFunction(filters[i])) {
              filter = filters[i];
            } else {
              return error('filter', property, typeof filters[i], schema, errors, 'bad filter type: %{actual}');
            }
            try {
              // filter value for simple value or for an array item
              if (indexInArray == null) {
                object[property] = filter(object[property]);  
              } else {
                object[property][indexInArray] = filter(object[property][indexInArray]);
              }
            } catch(err) {
              return error('filter', property, err, schema, errors, 'error during filtering: %{actual}');
            }
          }
        } else {
          return error('filter', property, type, schema, errors, 'bad property type for filtering: %{actual}');
        }
      }
    });
  }
436623
function validPPBBox(bBox) {
  if (!isObject(bBox)) {
    return null;
  }
  var ppValue = void 0;
  if ((ppValue = validPPValue(bBox.left)) || (ppValue = validPPValue(bBox.x))) {
    bBox.left = bBox.x = ppValue;
  } else {
    return null;
  }
  if ((ppValue = validPPValue(bBox.top)) || (ppValue = validPPValue(bBox.y))) {
    bBox.top = bBox.y = ppValue;
  } else {
    return null;
  }

  if ((ppValue = validPPValue(bBox.width)) && ppValue.value >= 0) {
    bBox.width = ppValue;
    delete bBox.right;
  } else if (ppValue = validPPValue(bBox.right)) {
    bBox.right = ppValue;
    delete bBox.width;
  } else {
    return null;
  }
  if ((ppValue = validPPValue(bBox.height)) && ppValue.value >= 0) {
    bBox.height = ppValue;
    delete bBox.bottom;
  } else if (ppValue = validPPValue(bBox.bottom)) {
    bBox.bottom = ppValue;
    delete bBox.height;
  } else {
    return null;
  }
  return bBox;
}
1007391
function(bbox) {
        var coords = this._toIndexKey(bbox);
        var array = this._rtree.search(coords);
        array = this._sortByDistance(array, bbox);
        var result = [];
        var filterMultiPoints = !!this.options.filterPoints;
        for (var i = 0; i < array.length; i++) {
            var arr = array[i];
            var r = arr.data;
            var geometry = this.getGeometry(r);
            var handled = false;
            GeoJsonUtils.forEachGeometry(geometry, {
                onPoints : function(points) {
                    if (!handled
                            && (!filterMultiPoints || GeometryUtils
                                    .bboxContainsPoints(points, bbox))) {
                        result.push(r);
                        handled = true;
                    }
                },
                onLines : function(lines) {
                    if (!handled
                            && GeometryUtils.bboxIntersectsLines(lines, bbox)) {
                        result.push(r);
                        handled = true;
                    }
                },
                onPolygons : function(polygons) {
                    if (!handled
                            && GeometryUtils.bboxIntersectsPolygonsWithHoles(
                                    polygons, bbox)) {
                        result.push(r);
                        handled = true;
                    }
                }
            });
        }
        return result;
    }