Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw on Cesium map feature #2204

Merged
merged 25 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
76f40f0
Create structure for tool for drawing on map [WIP]
robyngit Aug 23, 2023
ddb9543
Update Cesium on add/remove layers collection
robyngit Aug 24, 2023
ef5afac
Expand on DrawTool methods, add to ToolbarView
robyngit Aug 24, 2023
24c8050
Improve Cesium Map models, views, & collections
robyngit Aug 31, 2023
0668c24
Add unit tests for new map models
robyngit Sep 6, 2023
e2d5bde
Fix issues with selected features in Cesium Map
robyngit Sep 20, 2023
90fdc5c
Ensure layer is visible after load error is fixed
robyngit Sep 20, 2023
ef72df5
Enable basic drawing on Cesium map
robyngit Sep 20, 2023
0fc87fb
Add connector & collection for drawing on map
robyngit Sep 21, 2023
92e29eb
Add buttons & actions to DrawToolView; use CZML
robyngit Sep 28, 2023
c89ff99
Speed up vector layer rendering, fix drawing
robyngit Oct 6, 2023
6ff2d85
Rerun visualizers until async processes complete
robyngit Oct 13, 2023
2926dec
Minor changes to draw tool UI
robyngit Oct 13, 2023
516cd60
Fix opacity of draw tool polygon
robyngit Oct 13, 2023
7f4103b
Update polygon on draw rather than add new one
robyngit Oct 16, 2023
b245cca
Fix geo tests & minor bugs found while testing
robyngit Oct 17, 2023
f7d6ddf
Fix Cesium datasource issues & minor draw tool bug
robyngit Oct 18, 2023
e24b8c6
Complete unit tests for new geo models & coll'ns
robyngit Oct 18, 2023
b8e7ba9
Add moveStartAndCameraChanged event to map
robyngit Nov 1, 2023
67be6be
Fix taxa persisting between editor sessions bug
robyngit Oct 25, 2023
dc471e4
Improve error handling of view service response
robyngit Oct 25, 2023
703883e
Prevent weird TOC placement in portals
robyngit Oct 26, 2023
713f528
Adjust height of feature info panel in Cesium map
robyngit Oct 26, 2023
187351c
Allow all users to set datasets to private on KNB
robyngit Oct 26, 2023
f810d7c
Fix check for visualizers in CesiumVectorData
robyngit Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/css/map-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
font-size: 1rem;
}

.map-view__button--active {
background-color: var(--map-col-highlight);
}

/* ---- BADGE ---- */

.map-view__badge{
Expand Down Expand Up @@ -953,4 +957,18 @@ other class: .ui-slider-range */
box-shadow: var(--map-shadow-md);
/* imagery appears lighter on the map */
filter: brightness(1.75);
}
}

/*****************************************************************************************
*
* Draw Tool
*
* Panel for drawing polygons in the map
*
*/

.draw-tool {
display: grid;
grid-auto-rows: min-content;
grid-gap: 1rem;
}
227 changes: 110 additions & 117 deletions src/js/collections/maps/Features.js
Original file line number Diff line number Diff line change
@@ -1,125 +1,118 @@
'use strict';
"use strict";

define(
[
'jquery',
'underscore',
'backbone',
'models/maps/Feature'
],
function (
$,
_,
Backbone,
Feature
) {
define(["jquery", "underscore", "backbone", "models/maps/Feature"], function (
$,
_,
Backbone,
Feature
) {
/**
* @class Features
* @classdesc A Features collection contains the relevant properties of a group of
* selected geo-spatial features from a map.
* @class Features
* @classcategory Collections/Maps
* @extends Backbone.Collection
* @since 2.18.0
* @constructor
*/
var Features = Backbone.Collection.extend(
/** @lends Features.prototype */ {
/**
* The class/model that this collection contains.
* @type {Backbone.Model}
*/
model: Feature,

/**
* @class Features
* @classdesc A Features collection contains the relevant properties of a group of
* selected geo-spatial features from a map.
* @class Features
* @classcategory Collections/Maps
* @extends Backbone.Collection
* @since 2.18.0
* @constructor
*/
var Features = Backbone.Collection.extend(
/** @lends Features.prototype */ {
/**
* Get an array of all of the unique Map Assets that are associated with this
* collection. (When a feature model is part of a layer, it will have the layer
* model (Map Asset) set as a property)
* @returns {MapAsset[]} Returns an a array of all the unique Map Assets (imagery,
* tile sets, etc.) in this collection.
*/
getMapAssets: function () {
return this.getUniqueAttrs("mapAsset");
},

/**
* The class/model that this collection contains.
* @type {Backbone.Model}
*/
model: Feature,
/**
* Get an array of all the unique feature objects associated with this collection.
* @param {string} [type] Optionally set a type of feature to return. If set, then
* only features that have this constructor name will be returned.
* @returns {Array} Returns an array of all of the unique feature objects in the
* collection. Feature objects are the objects used by the map widget to represent
* a feature in the map. For example, in Cesium this could be a
* Cesium3DTileFeature or an Entity.
*/
getFeatureObjects: function (type) {
let featureObjects = this.getUniqueAttrs("featureObject");
if (type) {
featureObjects = featureObjects.filter(function (featureObject) {
return featureObject.constructor.name === type;
});
}
return featureObjects;
},

/**
* Get an array of all of the unique Map Assets that are associated with this
* collection. (When a feature model is part of a layer, it will have the layer
* model (Map Asset) set as a property)
* @returns {MapAsset[]} Returns an a array of all the unique Map Assets (imagery,
* tile sets, etc.) in this collection.
*/
getMapAssets: function () {
return this.getUniqueAttrs('mapAsset')
},
/**
* Get an array of unique values for some attribute that may be set on the models
* in this collection
* @param {string} attrName The name of the attr to get unique values for
* @returns {Array} Returns an array of unique values of the given attribute
*/
getUniqueAttrs: function (attrName) {
try {
let uniqueAttrs = [];
this.each(function (featureModel) {
const attr = featureModel.get(attrName);
if (attr && !uniqueAttrs.includes(attr)) {
uniqueAttrs.push(attr);
}
});
return uniqueAttrs;
} catch (error) {
console.log(
`Failed to get unique attributes for "${attrName}".`,
error
);
}
},

/**
* Get an array of all the unique feature objects associated with this collection.
* @param {string} [type] Optionally set a type of feature to return. If set, then
* only features that have this constructor name will be returned.
* @returns {Array} Returns an array of all of the unique feature objects in the
* collection. Feature objects are the objects used by the map widget to represent
* a feature in the map. For example, in Cesium this could be a
* Cesium3DTileFeature or an Entity.
*/
getFeatureObjects: function (type) {
let featureObjects = this.getUniqueAttrs('featureObject')
if (type) {
featureObjects = featureObjects.filter(function (featureObject) {
return featureObject.constructor.name === type
})
}
return featureObjects
},
/**
* Checks if a given feature object is an attribute in one of the Feature models
* in this collection.
* @param {Feature|Cesium.Cesium3DTilesetFeature|Cesium.Entity} featureObject
* @returns {boolean} Returns true if the given feature object is in this
* collection, false otherwise.
* @since 2.25.0
*/
containsFeature: function (featureObject) {
if (this.models.length === 0) return false;
if (!featureObject) return false;
featureObject =
featureObject instanceof Feature
? featureObject.get("featureObject")
: featureObject;
return this.findWhere({ 'featureObject': featureObject }) ? true : false;
},

/**
* Get an array of unique values for some attribute that may be set on the models
* in this collection
* @param {string} attrName The name of the attr to get unique values for
* @returns {Array} Returns an array of unique values of the given attribute
*/
getUniqueAttrs: function (attrName) {
try {
let uniqueAttrs = []
this.each(function (featureModel) {
const attr = featureModel.get(attrName)
if (attr && !uniqueAttrs.includes(attr)) {
uniqueAttrs.push(attr)
}
})
return uniqueAttrs
}
catch (error) {
console.log(
'Failed to get unique values for an attribute in a Features collection' +
'. Error details: ' + error
);
}
},
/**
* Checks if a given array of feature objects are attributes in one of the
* Feature models in this collection.
* @param {Array} featureObjects An array of feature objects to check if they are
* in this collection.
* @returns {boolean} Returns true if all of the given feature objects are in this
* collection, false otherwise.
*/
containsFeatures: function (featureObjects) {
if (!featureObjects || !featureObjects.length) return false;
return featureObjects.every((featureObject) =>
this.containsFeature(featureObject)
);
},

/**
* Checks if a given feature object is an attribute in one of the Feature models
* in this collection.
* @param {Feature|Cesium.Cesium3DTilesetFeature|Cesium.Entity} featureObject
* @returns {boolean} Returns true if the given feature object is in this
* collection, false otherwise.
* @since 2.25.0
*/
containsFeature: function (featureObject) {
if (!featureObject) return false;
featureObject = featureObject instanceof Feature ? featureObject.get('featureObject') : featureObject;
return this.findWhere({ featureObject: featureObject }) ? true : false;
},
}
);

/**
* Checks if a given array of feature objects are attributes in one of the
* Feature models in this collection.
* @param {Array} featureObjects An array of feature objects to check if they are
* in this collection.
* @returns {boolean} Returns true if all of the given feature objects are in this
* collection, false otherwise.
*/
containsFeatures: function (featureObjects) {
if (!featureObjects || !featureObjects.length) return false;
return featureObjects.every(
(featureObject) => this.containsFeature(featureObject));
},

}
);

return Features;

}
);
return Features;
});
Loading