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

AddPart - first geometry #86

Open
1 task done
FITCODE1 opened this issue Jan 11, 2024 · 3 comments
Open
1 task done

AddPart - first geometry #86

FITCODE1 opened this issue Jan 11, 2024 · 3 comments
Assignees
Labels
feature New feature or request

Comments

@FITCODE1
Copy link

Checklist

  • I've searched through the current issues to make sure this feature hasn't been requested already.

Motivation

Hi,

I searched through the G3W functionalities and documentation for possibility of adding first geometry to a feature in G3W, exception of Add Part to Multipart - Screenshot01. Also I've searched through the GIT issues to make sure this feature hasn't been requested already. I hope I didn't miss something. If so, I apologize in advance.

In the scenario where I import features without geometry into a QGIS layer, is there a possibility to add first geometry to from G3W Client, function similar to AddPart from QGIS (Screenshot02)? If not, I would like to know

  1. it is possible to develop this feature?
  2. when it could be available?

Regars,

Alin

Suggested solution

Adding an AddPart button next to the already existing Add part to multipart button .

Usage Flow:
Step 1. The user will select the feature of interest from the Attributes Table
Step 2. Select the AddPart button
Step 3. Draw point / line / polygon.
Step 4. Saving change ,

That geometry will be automatically associated with the previously selected feature.

Alternatives considered

Screenshot 01 Screenshot 02
@FITCODE1 FITCODE1 added the feature New feature or request label Jan 11, 2024
@volterra79 volterra79 transferred this issue from g3w-suite/g3w-admin Jan 11, 2024
@volterra79
Copy link
Member

volterra79 commented Jan 11, 2024

@FITCODE1 we evaluate it. Thanks

@Raruto
Copy link
Collaborator

Raruto commented Jan 12, 2024

Hi @FITCODE1,

  1. is is possible to develop this feature?
  2. when it could be available?

Next stable G3W-SUITE release is expected to happen in 6 months, so June 2024 (the next one at the end of 2024).

Usually, sponsored features are more likely to be implemented sooner, in this case contact [email protected] to get in touch with the sales department.

Otherwise, just propose your own PR to speed things up.

Below almost all the code that handles the "Add part to multipart" button (you can use that as a starting point to create a your own button):

...(isMultiGeometry ? [
{
config: {
id: 'addPart',
name: "editing.tools.addpart",
icon: "addPart.png",
layer,
once: true,
row: 3,
op: AddPartToMultigeometriesWorkflow,
type: ['add_feature', 'change_feature']
}
}
] : []),

...(isMultiGeometry ? [
{
config: {
id: 'addPart',
name: "editing.tools.addpart",
icon: "addPart.png",
layer,
row: 3,
once: true,
op: AddPartToMultigeometriesWorkflow,
type: ['add_feature', 'change_feature']
}
}
] : []),

const { base, inherit } = g3wsdk.core.utils;
const EditingWorkflow = require('./editingworkflow');
const PickFeatureStep = require('./steps/pickfeaturestep');
const ChooseFeatureStep = require('./steps/choosefeaturestep');
const AddFeatureStep = require('./steps/addfeaturestep');
const AddPartToMultigeometriesStep = require('./steps/addparttomultigeometriesstep');
function AddPartToMultigeometriesWorflow(options={}) {
options.type = 'single';
options.helpMessage = 'editing.tools.addpart';
options.help = 'editing.steps.help.select_element';
const selectelementssteps = new PickFeatureStep();
selectelementssteps.getTask().setSteps({
select: {
description: 'editing.workflow.steps.select',
directive: 't-plugin',
done: false
}
});
options.add = false;
const addfeaturestep = new AddFeatureStep(options);
addfeaturestep.getTask().setSteps({
addfeature: {
description: 'editing.workflow.steps.draw_part',
directive: 't-plugin',
done: false
}
});
addfeaturestep.on('run', ({inputs, context}) => {
const layer = inputs.layer;
const snapTool = {
type: 'snap',
options: {
layerId: layer.getId(),
source: layer.getEditingLayer().getSource(),
active: true
}
};
this.emit('settoolsoftool', [snapTool]);
});
addfeaturestep.on('run', () => {
this.emit('active', ['snap']);
});
addfeaturestep.on('stop', () => {
this.emit('deactive', ['snap']);
});
const addparttogeometriesstep = new AddPartToMultigeometriesStep(options);
options.steps = [selectelementssteps, new ChooseFeatureStep(), addfeaturestep, addparttogeometriesstep];
this.registerEscKeyEvent();
base(this, options);
}
inherit(AddPartToMultigeometriesWorflow, EditingWorkflow);
module.exports = AddPartToMultigeometriesWorflow;

const {base, inherit} = g3wsdk.core.utils;
const EditingStep = require('./editingstep');
const AddPartToMuligeometriesTask = require('./tasks/addparttomultigeometriestask');
const AddPartToMuligeometriesStep = function(options={}) {
options.task = new AddPartToMuligeometriesTask(options);
base(this, options)
};
inherit(AddPartToMuligeometriesStep, EditingStep);
module.exports = AddPartToMuligeometriesStep;

const { base, inherit } = g3wsdk.core.utils;
const EditingTask = require('./editingtask');
function AddPartToMuligeometriesTask(options={}) {
base(this, options);
}
inherit(AddPartToMuligeometriesTask, EditingTask);
const proto = AddPartToMuligeometriesTask.prototype;
proto.run = function(inputs, context) {
const d = $.Deferred();
const { layer, features } = inputs;
const layerId = layer.getId();
const session = context.session;
const feature = features[0];
const featureGeometry = feature.getGeometry();
const originalFeature = feature.clone();
featureGeometry.setCoordinates([...featureGeometry.getCoordinates(), ...features[1].getGeometry().getCoordinates()]);
/**
* evaluated geometry expression
*/
this.evaluateExpressionFields({
inputs,
context,
feature
}).finally(()=>{
session.pushUpdate(layerId, feature, originalFeature);
inputs.features = [feature];
d.resolve(inputs);
});
/**
* end of evaluated
*/
return d.promise();
};
proto.stop = function() {
};
module.exports = AddPartToMuligeometriesTask;

In this folder the base classes that are provided by the core g3w-client repository: g3w-client/src/app/core/workflow

👋 Raruto

@FITCODE1
Copy link
Author

FITCODE1 commented Jan 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants