Load vector from geojson.
504217
def from_geojson(cls, filename):
        """"""
        with open(filename) as fd:
            geometry = json.load(fd)

        if 'type' not in geometry:
            raise TypeError("%s is not a valid geojson." % (filename,))

        return cls(to_shape(geometry), WGS84_CRS)
974074
function toGeoJSON(json, options = Options) {
  const collection = helpers.featureCollection([])
  json.resourceSets[0].resources.map(result => {
    // Point GeoJSON
    const point = parsePoint(result)
    const bbox = parseBBox(result)
    let confidence = confidenceScore(bbox)
    const properties = {
      confidence,
      authenticationResultCode: json.authenticationResultCode,
      brandLogoUri: json.brandLogoUri,
      copyright: json.copyright,
      entityType: result.entityType,
      matchCodes: result.matchCodes,
      name: result.name,
      statusCode: json.statusCode,
      statusDescription: json.statusDescription,
      traceId: json.traceId,
    }
    Object.keys(result.address).forEach(key => properties[key] = result.address[key])

    // Store Point to GeoJSON feature collection
    if (point) {
      point.bbox = bbox
      point.properties = properties
      collection.features.push(point)
    }
  })
  return collection
}
493954
def prepare_geojson(geojson):
    
    # TODO CW orientation.
    geojson = deepcopy(geojson)

    if geojson["type"] == "Feature":
        geojson = geojson["geometry"]
        if hasattr(geojson, 'properties'):
            del geojson['properties']

    if geojson["type"] == "FeatureCollection":
        geojson["type"] = "GeometryCollection"
        geojson["geometries"] = [
            feature["geometry"] for feature in geojson["features"]
        ]
        del geojson["features"]

    return geojson
402362
function fromOverlaysToJSON_(geom) {
  var gtype = getGeometryType_(geom);
  var g, gs, i, pts;
  var json = '{';
  switch (gtype) {
  case GeometryType.POINT:
    g = isArray_(geom) ? geom[0] : geom;
    if (g instanceof G.Marker) {
      g = g.getPosition();
    }
    json += 'x:' + g.lng() + ',y:' + g.lat();
    break;
  case GeometryType.MULTIPOINT:
    pts = [];
    for (i = 0; i < geom.length; i++) {
      if (geom[i] instanceof G.Marker) {
        g = geom[i].getPosition();
      } else {
        g = geom[i];
      }
      pts.push('[' + g.lng() + ',' + g.lat() + ']');
    }
    json += 'points: [' + pts.join(',') + ']';
    break;
  case GeometryType.POLYLINE:
    // V3 does not support multiple paths yet
    pts = [];
    gs = isArray_(geom) ? geom : [geom];
    for (i = 0; i < gs.length; i++) {
      pts.push('[' + fromLatLngsToJSON_(gs[i].getPath()) + ']');
    }
    json += 'paths:[' + pts.join(',') + ']';
    break;
  case GeometryType.POLYGON:
    pts = [];
    g = isArray_(geom) ? geom[0] : geom;
    var paths = g.getPaths();
    for (i = 0; i < paths.getLength(); i++) {
      pts.push('[' + fromLatLngsToJSON_(paths.getAt(i), true) + ']');
    }
    json += 'rings:[' + pts.join(',') + ']';
    
    break;
  case GeometryType.ENVELOPE:
    g = isArray_(geom) ? geom[0] : geom;
    json += 'xmin:' + g.getSouthWest().lng() + ',ymin:' + g.getSouthWest().lat() + ',xmax:' + g.getNorthEast().lng() + ',ymax:' + g.getNorthEast().lat();
    break;
  }
  json += ', spatialReference:{wkid:4326}';
  json += '}';
  return json;
}
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self
135335
def _read_geojson_features(data, features=None, prefix=""):
        """"""
        if features is None:
            features = collections.OrderedDict()
        for i, feature in enumerate(data['features']):
            key = feature.get('id', prefix + str(i))
            feature_type = feature['geometry']['type']
            if feature_type == 'FeatureCollection':
                _read_geojson_features(feature, features, prefix + '.' + key)
            elif feature_type == 'Point':
                value = Circle._convert_point(feature)
            elif feature_type in ['Polygon', 'MultiPolygon']:
                value = Region(feature)
            else:
                # TODO Support all http://geojson.org/geojson-spec.html#geometry-objects
                value = None
            features[key] = value
        return features
53083
def loads(s):
    """"""
    _decoder = json.JSONDecoder()

    while s:
        s = s.strip()
        obj, pos = _decoder.raw_decode(s)
        if not pos:
            raise ValueError('no JSON object found at %i' % pos)
        yield obj
        s = s[pos:]
783488
def load_from_stream(self, var):
        """"""
        dims = []
        for d in var.shape:
            dim = Dimension(None, d.name)
            dim.load_from_stream(d)
            dims.append(dim)

        self.dimensions = tuple(dim.name for dim in dims)
        self.shape = tuple(dim.size for dim in dims)
        self.ndim = len(var.shape)
        self._unpack_attrs(var.atts)

        data, dt, type_name = unpack_variable(var)
        if data is not None:
            data = data.reshape(self.shape)
        self._data = data
        self.dtype = dt
        self.datatype = type_name

        if hasattr(var, 'enumType') and var.enumType:
            self.datatype = var.enumType
            self._enum = True
697495
def probably_geojson(input):
    ''''''
    valid = False
    if not isinstance(input, dict):
        try:
            input = json.loads(input)
        except ValueError:
            return None
    typename = input.get('type', None)
    supported_types = set([
        'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString',
        'MultiPolygon', 'GeometryCollection', 'Feature', 'FeatureCollection'
    ])
    valid = typename in supported_types
    return input if valid else None
1206140
public static DenseVector fromMap(Map<Integer, ? extends Number> map, int length) {
        return Vector.fromMap(map, length).to(Vectors.DENSE);
    }
307470
def load(self, filename):
        """"""
        content = open(filename)
        return Config(json.load(content))
397166
def loads(s, as_dict=False, *args, **kwargs):
    
    if as_dict or (not isinstance(s, six.string_types)):
        s = json.dumps(s)
    kwargs['object_hook'] = object_hook
    return json.loads(s, *args, **kwargs)
1130218
def from_geojson(geojson, srid=4326):
        
        type_ = geojson["type"].lower()
        if type_ == "geometrycollection":
            geometries = []
            for geometry in geojson["geometries"]:
                geometries.append(Geometry.from_geojson(geometry, srid=None))
            return GeometryCollection(geometries, srid)
        elif type_ == "point":
            return Point(geojson["coordinates"], srid=srid)
        elif type_ == "linestring":
            return LineString(geojson["coordinates"], srid=srid)
        elif type_ == "polygon":
            return Polygon(geojson["coordinates"], srid=srid)
        elif type_ == "multipoint":
            geometries = _MultiGeometry._multi_from_geojson(geojson, Point)
            return MultiPoint(geometries, srid=srid)
        elif type_ == "multilinestring":
            geometries = _MultiGeometry._multi_from_geojson(geojson, LineString)
            return MultiLineString(geometries, srid=srid)
        elif type_ == "multipolygon":
            geometries = _MultiGeometry._multi_from_geojson(geojson, Polygon)
            return MultiPolygon(geometries, srid=srid)
150195
public static GeoShape fromJson(String json) {
        try {
            return JsonSerializer.fromString(json, GeoShape.class);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unparseable shape");
        }
    }
173848
def load(cls, serialized_index):
        """"""
        from lunr import __TARGET_JS_VERSION__

        if isinstance(serialized_index, basestring):
            serialized_index = json.loads(serialized_index)

        if serialized_index["version"] != __TARGET_JS_VERSION__:
            logger.warning(
                "Version mismatch when loading serialized index. "
                "Current version of lunr {} does not match that of serialized "
                "index {}".format(__TARGET_JS_VERSION__, serialized_index["version"])
            )

        field_vectors = {
            ref: Vector(elements) for ref, elements in serialized_index["fieldVectors"]
        }

        tokenset_builder = TokenSetBuilder()
        inverted_index = {}
        for term, posting in serialized_index["invertedIndex"]:
            tokenset_builder.insert(term)
            inverted_index[term] = posting

        tokenset_builder.finish()

        return Index(
            fields=serialized_index["fields"],
            field_vectors=field_vectors,
            inverted_index=inverted_index,
            token_set=tokenset_builder.root,
            pipeline=Pipeline.load(serialized_index["pipeline"]),
        )
741059
def from_dict(self, the_dict):
        
        geom = geojson.loads(json.dumps(the_dict))
        result = MultiPolygon([
            [[[0, 0], [0, 0]]],
            [[[1, 1], [1, 1]]]
        ])
        result._geom = geom
        return result
6925
def format(self, **kwargs):
        """"""
        attrs = self._attrs.copy()
        attrs.update(kwargs)
        return Region(self._geojson, **attrs)