Skip to content

Commit

Permalink
Pass all properties when creating midpoints and vertices, close mapbo…
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbo committed Dec 13, 2018
1 parent e252c53 commit f03ce78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/lib/create_midpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module.exports = function(parent, startVertex, endVertex, map) {
return {
type: Constants.geojsonTypes.FEATURE,
properties: {
...parent.properties,
meta: Constants.meta.MIDPOINT,
parent: parent,
parent: parent.id,
lng: mid.lng,
lat: mid.lat,
coord_path: endVertex.properties.coord_path
Expand All @@ -31,4 +32,6 @@ module.exports = function(parent, startVertex, endVertex, map) {
coordinates: [mid.lng, mid.lat]
}
};


};
6 changes: 3 additions & 3 deletions src/lib/create_supplementary_points.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createSupplementaryPoints(geojson, options = {}, basePath = null) {

if (type === Constants.geojsonTypes.POINT) {
// For points, just create a vertex
supplementaryPoints.push(createVertex(featureId, coordinates, basePath, isSelectedPath(basePath)));
supplementaryPoints.push(createVertex(geojson, coordinates, basePath, isSelectedPath(basePath)));
} else if (type === Constants.geojsonTypes.POLYGON) {
// Cycle through a Polygon's rings and
// process each line
Expand All @@ -28,13 +28,13 @@ function createSupplementaryPoints(geojson, options = {}, basePath = null) {
let lastVertex = null;
line.forEach((point, pointIndex) => {
const pointPath = (lineBasePath !== undefined && lineBasePath !== null) ? `${lineBasePath}.${pointIndex}` : String(pointIndex);
const vertex = createVertex(featureId, point, pointPath, isSelectedPath(pointPath));
const vertex = createVertex(geojson, point, pointPath, isSelectedPath(pointPath));

// If we're creating midpoints, check if there was a
// vertex before this one. If so, add a midpoint
// between that vertex and this one.
if (options.midpoints && lastVertex) {
const midpoint = createMidpoint(featureId, lastVertex, vertex, options.map);
const midpoint = createMidpoint(geojson, lastVertex, vertex, options.map);
if (midpoint) {
supplementaryPoints.push(midpoint);
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/create_vertex.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ const Constants = require('../constants');
* @param {boolean} selected
* @return {GeoJSON} Point
*/
module.exports = function(parentId, coordinates, path, selected) {
module.exports = function(parent, coordinates, path, selected) {
return {
type: Constants.geojsonTypes.FEATURE,
properties: {
...parent.properties,
meta: Constants.meta.VERTEX,
parent: parentId,
parent: parent.id,
coord_path: path,
active: (selected) ? Constants.activeStates.ACTIVE : Constants.activeStates.INACTIVE
},
Expand Down

0 comments on commit f03ce78

Please sign in to comment.