Skip to content

Commit

Permalink
Add bbox and some docs corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
servetg committed Sep 24, 2015
1 parent 54f5c00 commit 340762e
Show file tree
Hide file tree
Showing 14 changed files with 504 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
api-doc/
worldwindlib.js
WebWorldWind.zip
node_modules/
node_modules/
297 changes: 218 additions & 79 deletions .idea/workspace.xml

Large diffs are not rendered by default.

163 changes: 113 additions & 50 deletions src/formats/geojson/GeoJSON.js

Large diffs are not rendered by default.

31 changes: 22 additions & 9 deletions src/formats/geojson/GeoJSONCRS.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,35 @@ define(['../../error/ArgumentError',

/**
* Constructs a GeoJSON CRS object. Applications typically do not call this constructor. It is called by
* {@link GeoJSONGeometry} ,{@link GeoJSONFeature} or {@link GeoJSONGeometry}.
* {@link GeoJSONGeometry}, {@link GeoJSONGeometryCollection}, {@link GeoJSONFeature} or
* {@link GeoJSONFeatureCollection}.
* @alias GeoJSONCRS
* @constructor
* @classdesc Contains the data associated with a GeoJSON Coordinate Reference System object.
* The coordinate reference system (CRS) of a GeoJSON object is determined by its "crs" member (referred to as
* the CRS object below).
* If an object has no crs member, then its parent or grandparent object's crs member may be acquired.
* If no crs member can be so acquired, the default CRS shall apply to the GeoJSON object.
* The default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude and
* latitude units of decimal degrees.
* <p>
* There are two types of CRS objects:
* <ul>
* <li>Named CRS</li>
* <li>Linked CRS</li>
* </ul>
* In this implementation we consider only named CRS. In this case, the value of its "type" member must be
* the string "name". The value of its "properties" member must be an object containing a "name" member.
* The value of that "name" member must be a string identifying a coordinate reference system.
* OGC CRS URNs such as "urn:ogc:def:crs:OGC:1.3:CRS84" shall be preferred over legacy identifiers
* such as "EPSG:4326".
* <p>
* At the moment is implemented only "urn:ogc:def:crs:OGC:1.3:CRS84".
* @param {String} type A string, indicating the type of CRS object.
* @param {Object} properties An object containing the properties of CRS object.
* @throws {ArgumentError} If the specified type or properties are null or undefined.
*/
var GeoJSONCRS = function (type, properties) {
/*
The coordinate reference system (CRS) of a GeoJSON object is determined by its "crs" member (referred to as the CRS object below).
If an object has no crs member, then its parent or grandparent object's crs member may be acquired.
If no crs member can be so acquired, the default CRS shall apply to the GeoJSON object.
The default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude and latitude units of decimal degrees.
*/

if (!type) {
throw new ArgumentError(
Logger.logMessage(Logger.LEVEL_SEVERE, "GeoJSONCRS", "constructor",
Expand Down Expand Up @@ -66,7 +79,7 @@ define(['../../error/ArgumentError',
/**
* The GeoJSON CRS object properties as specified to this GeoJSON CRS's constructor.
* @memberof GeoJSONCRS.prototype
* @type {String}
* @type {Object}
* @readonly
*/
properties: {
Expand Down
31 changes: 26 additions & 5 deletions src/formats/geojson/GeoJSONFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ define(['../../error/ArgumentError',
* {@link GeoJSON} as GeoJSON is read.
* @alias GeoJSONFeature
* @constructor
* @classdesc Contains the data associated with a GeoJSON Feature Object. A feature object must have a member with the name "geometry".
* The value of the geometry member is a geometry object or a JSON null value.A feature object must have a member with the name "properties".
* @classdesc Contains the data associated with a GeoJSON Feature Object.
* A feature object must have a member with the name "geometry".
* The value of the geometry member is a geometry object or a JSON null value.
* A feature object must have a member with the name "properties".
* The value of the properties member is an object (any JSON object or a JSON null value).
* If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name "id".
* If a feature has a commonly used identifier, that identifier should be included as a member of the
* feature object with the name "id".
* To include information on the coordinate range for features, a GeoJSON object may have a member named "bbox".
* @param {Object} geometry An object containing the value of GeoJSON geometry member.
* @param {Object} properties An object containing the value of GeoJSON properties member.
* @param {Object} crs An object containing the value of GeoJSON FeatureCollection or Feature crs member.
* @param {Object} id An object containing the value of GeoJSON Feature id member.
* @param {Object} bbox An object containing the value of GeoJSON Feature bbox member.
* @throws {ArgumentError} If the specified mandatory geometries or properties are null or undefined.
*/
var GeoJSONFeature = function (geometry, properties, crs, id) {
var GeoJSONFeature = function (geometry, properties, crs, id, bbox) {

if (!geometry) {
throw new ArgumentError(
Expand All @@ -58,10 +63,15 @@ define(['../../error/ArgumentError',
this._properties = properties;

// Documented in defineProperties below.
this._crs = crs ? new GeoJSONCRS(crs[GeoJSONConstants.FIELD_TYPE], crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;
this._crs = crs ? new GeoJSONCRS(
crs[GeoJSONConstants.FIELD_TYPE],
crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;

// Documented in defineProperties below.
this._id = id;

// Documented in defineProperties below.
this._bbox = bbox;
};

Object.defineProperties(GeoJSONFeature.prototype, {
Expand Down Expand Up @@ -108,6 +118,17 @@ define(['../../error/ArgumentError',
get: function () {
return this._id;
}
},
/**
* The GeoJSON Feature bbox member as specified to this GeoJSONFeature's constructor.
* @memberof GeoJSONFeature.prototype
* @type {Object}
* @readonly
*/
bbox: {
get: function () {
return this._bbox;
}
}
});

Expand Down
30 changes: 25 additions & 5 deletions src/formats/geojson/GeoJSONFeatureCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ define(['../../error/ArgumentError',
"use strict";

/**
* Constructs a GeoJSON FeatureCollection object. Applications typically do not call this constructor. It is called by
* {@link GeoJSON} as GeoJSON is read.
* Constructs a GeoJSON FeatureCollection object. Applications typically do not call this constructor.
* It is called by {@link GeoJSON} as GeoJSON is read.
* @alias GeoJSONFeatureCollection
* @constructor
* @classdesc Contains the data associated with a GeoJSON Feature Collection Object.
* An object of type "FeatureCollection" must have a member with the name "features".
* The value corresponding to "features" is an array. Each element in the array is a feature object as defined in {@link GeoJSONFeature}.
* The value corresponding to "features" is an array. Each element in the array is a feature object as
* defined in {@link GeoJSONFeature}.
* To include information on the coordinate range for feature collections, a GeoJSON object may have a member
* named "bbox".
* @param {Array} features An array containing the data associated with the GeoJSON FeatureCollection features.
* @param {Object} crs An object containing the value of GeoJSON FeatureCollection crs member.
* @param {Object} bbox An object containing the value of GeoJSON FeatureCollection bbox member.
* @throws {ArgumentError} If the specified mandatory features parameter is null or undefined.
*/
var GeoJSONFeatureCollection = function (features, crs) {
var GeoJSONFeatureCollection = function (features, crs, bbox) {

if (!features) {
throw new ArgumentError(
Expand All @@ -45,7 +49,12 @@ define(['../../error/ArgumentError',
this._features = features;

// Documented in defineProperties below.
this._crs = crs ? new GeoJSONCRS(crs[GeoJSONConstants.FIELD_TYPE], crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;
this._crs = crs ? new GeoJSONCRS(
crs[GeoJSONConstants.FIELD_TYPE],
crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;

// Documented in defineProperties below.
this._bbox = bbox;
};

Object.defineProperties(GeoJSONFeatureCollection.prototype, {
Expand All @@ -70,6 +79,17 @@ define(['../../error/ArgumentError',
get: function () {
return this._crs;
}
},
/**
* The GeoJSON Collection bbox member as specified to this GeoJSONFeatureCollection's constructor.
* @memberof GeoJSONFeatureCollection.prototype
* @type {Object}
* @readonly
*/
bbox: {
get: function () {
return this._bbox;
}
}
});

Expand Down
34 changes: 25 additions & 9 deletions src/formats/geojson/GeoJSONGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ define(['./GeoJSONConstants',
* @constructor
* @classdesc A geometry is a GeoJSON object where the type member's value is one of the following strings:
* "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", or "GeometryCollection".
* A GeoJSON geometry object of any type other than "GeometryCollection" must have a member with the name "coordinates".
* The value of the coordinates member is always an array. The structure for the elements in this array is determined by the type of geometry.
* @param {Array} coordinates he array containing geometry coordinates.
* A GeoJSON geometry object of any type other than "GeometryCollection" must have a member with the name
* "coordinates". The value of the coordinates member is always an array.
* The structure for the elements in this array is determined by the type of geometry.
* @param {Array} coordinates An array containing geometry coordinates.
* @param {String} type A string containing type of geometry.
* @param {Object} crs An object containing the value of GeoJSON crs member.
* @param {Object} bbox An array containing information on the coordinate range for geometries.
* @throws {ArgumentError} If the specified mandatory coordinates or type are null or undefined.
*/
var GeoJSONGeometry = function (coordinates, type, crs) {
var GeoJSONGeometry = function (coordinates, type, crs, bbox) {

if (!coordinates) {
throw new ArgumentError(
Expand All @@ -48,6 +50,9 @@ define(['./GeoJSONConstants',

// Documented in defineProperties below.
this._crs = crs ? new GeoJSONCRS(crs[GeoJSONConstants.FIELD_TYPE], crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;

// Documented in defineProperties below.
this._bbox = bbox ? bbox : null;
};

Object.defineProperties(GeoJSONGeometry.prototype, {
Expand All @@ -63,7 +68,18 @@ define(['./GeoJSONConstants',
}
},
/**
* The GeoJSON crs object.
* The GeoJSON geometry type as specified to this GeoJSONGeometry's constructor.
* @memberof GeoJSONGeometry.prototype
* @type {String}
* @readonly
*/
type: {
get: function () {
return this._type;
}
},
/**
* The GeoJSON crs object as specified to this GeoJSONGeometry's constructor.
* @memberof GeoJSONGeometry.prototype
* @type {Object}
* @readonly
Expand All @@ -74,14 +90,14 @@ define(['./GeoJSONConstants',
}
},
/**
* The GeoJSON geometry type as specified to this GeoJSONGeometry's constructor.
* The GeoJSON bbox object as specified to this GeoJSONGeometry's constructor.
* @memberof GeoJSONGeometry.prototype
* @type {String}
* @type {Object}
* @readonly
*/
type: {
bbox: {
get: function () {
return this._type;
return this._bbox;
}
}
});
Expand Down
31 changes: 26 additions & 5 deletions src/formats/geojson/GeoJSONGeometryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@
*/
define(['../../error/ArgumentError',
'./GeoJSONConstants',
'./GeoJSONCRS',
'../../util/Logger'
],
function (ArgumentError,
GeoJSONConstants,
GeoJSONCRS,
Logger) {
"use strict";

/**
* Constructs a GeoJSON geometry for a GeometryCollection. Applications typically do not call this constructor. It is called by
* {@link GeoJSON} as GeoJSON geometries are read.
* Constructs a GeoJSON geometry for a GeometryCollection. Applications typically do not call this constructor.
* It is called by {@link GeoJSON} as GeoJSON geometries are read.
* @alias GeoJSONGeometryCollection
* @constructor
* @classdesc Contains the data associated with a GeoJSON GeometryCollection geometry.
* A geometry collection must have a member with the name "geometries".
* The value corresponding to "geometries" is an array. Each element in this array is a GeoJSON geometry object.
* To include information on the coordinate range for features, a GeoJSON object may have a member named "bbox".
* @param {Array} geometries The array containing GeoJSONGeometry objects.
* @param {Object} crs An object containing GeoJSON CRS information.
* @throws {ArgumentError} If the specified mandatory geometries is null or undefined or if the geometries parameter is not an array of GeoJSONGeometry.
* @param {Object} bbox An object containing the value of GeoJSON GeometryCollection bbox member.
* @throws {ArgumentError} If the specified mandatory geometries is null or undefined or if the geometries
* parameter is not an array of GeoJSONGeometry.
*/
var GeoJSONGeometryCollection = function (geometries, crs) {
var GeoJSONGeometryCollection = function (geometries, crs, bbox) {
if (!geometries) {
throw new ArgumentError(
Logger.logMessage(Logger.LEVEL_SEVERE, "GeoJSONGeometryCollection", "constructor",
Expand All @@ -43,7 +48,12 @@ define(['../../error/ArgumentError',
this._geometries = geometries;

// Documented in defineProperties below.
this._crs = crs ? crs : null;
this._crs = crs ? new GeoJSONCRS(
crs[GeoJSONConstants.FIELD_TYPE],
crs[GeoJSONConstants.FIELD_PROPERTIES]) : null;

// Documented in defineProperties below.
this._bbox = bbox;
};

Object.defineProperties(GeoJSONGeometryCollection.prototype, {
Expand All @@ -68,6 +78,17 @@ define(['../../error/ArgumentError',
get: function () {
return this._crs;
}
},
/**
* The GeoJSON GeometryCollection bbox member as specified to this GeoJSONGeometryCollection's constructor.
* @memberof GeoJSONGeometryCollection.prototype
* @type {Object}
* @readonly
*/
bbox: {
get: function () {
return this._bbox;
}
}
});

Expand Down
12 changes: 7 additions & 5 deletions src/formats/geojson/GeoJSONGeometryLineString.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ define(['../../error/ArgumentError',
"use strict";

/**
* Constructs a GeoJSON geometry for a LineString. Applications typically do not call this constructor. It is called by
* {@link GeoJSON} as GeoJSON geometries are read.
* Constructs a GeoJSON geometry for a LineString. Applications typically do not call this constructor.
* It is called by {@link GeoJSON} as GeoJSON geometries are read.
* @alias GeoJSONGeometryLineString
* @constructor
* @classdesc Contains the data associated with a GeoJSON LineString geometry.
* @augments GeoJSONGeometry
* @param {Array} coordinates The array containing LineString coordinates.
* @param {String} type A string containing type of geometry.
* @param {Object} crs An object containing GeoJSON CRS information.
* @throws {ArgumentError} If the specified coordinates or type are null or undefined or if the coordinates parameter is not an array of two or more positions.
* @param {Object} bbox An object containing GeoJSON bbox information.
* @throws {ArgumentError} If the specified coordinates or type are null or undefined or if the coordinates
* parameter is not an array of two or more positions.
*/
var GeoJSONGeometryLineString = function (coordinates, type, crs) {
var GeoJSONGeometryLineString = function (coordinates, type, crs, bbox) {

if (!coordinates) {
throw new ArgumentError(
Expand All @@ -52,7 +54,7 @@ define(['../../error/ArgumentError',
"missingType"));
}

GeoJSONGeometry.call(this, coordinates, type, crs);
GeoJSONGeometry.call(this, coordinates, type, crs, bbox);
};

GeoJSONGeometryLineString.prototype = Object.create(GeoJSONGeometry.prototype);
Expand Down
12 changes: 7 additions & 5 deletions src/formats/geojson/GeoJSONGeometryMultiLineString.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ define(['../../error/ArgumentError',
"use strict";

/**
* Constructs a GeoJSON geometry for a MultiLineString. Applications typically do not call this constructor. It is called by
* {@link GeoJSON} as GeoJSON geometries are read.
* Constructs a GeoJSON geometry for a MultiLineString. Applications typically do not call this constructor.
* It is called by {@link GeoJSON} as GeoJSON geometries are read.
* @alias GeoJSONGeometryMultiLineString
* @constructor
* @classdesc Contains the data associated with a GeoJSON MultiLineString geometry.
* @augments GeoJSONGeometry
* @param {Array} coordinates The array containing MultiLineString coordinates.
* @param {String} type A string containing type of geometry.
* @param {Object} crs An object containing GeoJSON CRS information.
* @throws {ArgumentError} If the specified coordinates or type are null or undefined or if the coordinates parameter is not an array of LineString coordinates array.
* @param {Object} bbox An object containing GeoJSON bbox information.
* @throws {ArgumentError} If the specified coordinates or type are null or undefined or if the coordinates
* parameter is not an array of LineString coordinates array.
*/
var GeoJSONGeometryMultiLineString = function (coordinates, type, crs) {
var GeoJSONGeometryMultiLineString = function (coordinates, type, crs, bbox) {

if (!coordinates) {
throw new ArgumentError(
Expand All @@ -53,7 +55,7 @@ define(['../../error/ArgumentError',
"missingType"));
}

GeoJSONGeometry.call(this, coordinates, type, crs);
GeoJSONGeometry.call(this, coordinates, type, crs, bbox);
};

GeoJSONGeometryMultiLineString.prototype = Object.create(GeoJSONGeometry.prototype);
Expand Down
Loading

0 comments on commit 340762e

Please sign in to comment.