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

Kaavakohteiden ja kaavan muokkaaminen #112

Merged
merged 6 commits into from
Jan 21, 2025

Conversation

nmaarnio
Copy link
Collaborator

No description provided.

- add a custom QgsMapTool for selecting a plan feature to modify
- construct PlanFeatureForm from an existing feature
- update feature attributes, including regulation group associations
- fix duplicate PlanManager creation in plugin.py
@nmaarnio nmaarnio added the enhancement New feature or request label Jan 16, 2025
@nmaarnio nmaarnio linked an issue Jan 16, 2025 that may be closed by this pull request
@nmaarnio nmaarnio changed the title 110 kaavaan lisättyjen kaavakohteiden muokkaaminen Kaavakohteiden muokkaaminen Jan 17, 2025
Copy link
Contributor

@LKajan LKajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Kaavan ulkorajan tietoihin pitäisi myös päästä käsiksi. En tosin tiedä pitäisikö sille olla oma nappi vai pitäisikö sen antaa ulkoraja tuloslistaan vain, jos on klikannut reunaviivaa, muuten se ulkoraja on aina siinä menussa. Varsinkin kun ehdotin, että lomakkeen voisi avata suoraan jos vaan yksi kohde tuloksissa.
  • Spatiaalista indeksiä ei mun mielestä tässä tarvittaisi.

point = self.toMapCoordinates(event.pos())
nearby_features = self.query_nearby_features(point)

if nearby_features:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jos tuloksia on vain yksi, niin voisi suoraan avata lomakkeen. Jos tuloksia monta, niin silloin menu.

Copy link
Collaborator Author

@nmaarnio nmaarnio Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joo harkitsin tuota, mutta nyt kohde värjätään vasta kun menun elementtejä osoittaa hiirellä. Pitäisiköhän tehdä niin, että työkalun ollessa aktiivinen päällimäinen kohde värjätään silloinkin kun menu ei auki ja hiirtä vain liikutellaan, vai onko riittävän selkeää minkä kohteen lomake avataan ilmankin tuota, jos alle osuu vain yksi kohde?

@nmaarnio nmaarnio requested a review from LKajan January 20, 2025 12:34
@nmaarnio nmaarnio changed the title Kaavakohteiden muokkaaminen Kaavakohteiden ja kaavan muokkaaminen Jan 20, 2025
- add toolbar action for editing plan attributes
- modify plan model to allow Nones for all attributes
- add set_value methods for CodeComboBoxes
@nmaarnio nmaarnio force-pushed the 110-kaavaan-lisättyjen-kaavakohteiden-muokkaaminen branch from cb07da6 to 01fa4f2 Compare January 21, 2025 08:03
Copy link
Contributor

@LKajan LKajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hyvältä näyttää. Pari optimointi-kommenttia.

@classmethod
def get_associations_for_feature(cls, feature_id: str, layer_name: str) -> list[QgsFeature]:
attribute = cls.layer_name_to_attribute_map.get(layer_name)
return [feature for feature in cls.get_features() if feature[attribute] == feature_id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Olisi parempi hakea tietokannasta ainoastaan tarpeelliset kohteet. Nyt tää looppaa kaikki layerin kohteet läpi, mikä saattaa olla hidasta.
AbstractLayer:lle voisi toteuttaa esim metodin:

    @classmethod
    def get_features_by_attribute_value(cls, attribute: str, value: str) -> Generator[QgsFeature]:
        request = QgsFeatureRequest().setFilterExpression(f"\"{attribute}\"='{value}'")
        yield from cls.get_from_project().getFeatures(request)

def get_group_ids_for_feature(cls, feature_id: str, layer_name: str) -> list[str]:
attribute = cls.layer_name_to_attribute_map.get(layer_name)
return [
feature["plan_regulation_group_id"] for feature in cls.get_features() if feature[attribute] == feature_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sama juttu kuin yllä.
Tai oikeastaan, kun ollaan kiinnostuneita ainoastaan yhdestä arvosta, niin requestiin olisi hyvä lisätä

    request.setSubsetOfAttributes(['plan_regulation_group_id'], layer.fields())

, jotta tietokannan ja qgisin välillä liikkuisi mahdollisimman vähän dataa.

@nmaarnio nmaarnio force-pushed the 110-kaavaan-lisättyjen-kaavakohteiden-muokkaaminen branch from ff3f468 to 60aba95 Compare January 21, 2025 12:56
@nmaarnio nmaarnio merged commit 3992fcb into main Jan 21, 2025
7 checks passed
@nmaarnio nmaarnio deleted the 110-kaavaan-lisättyjen-kaavakohteiden-muokkaaminen branch January 21, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kaavaan lisättyjen kaavakohteiden muokkaaminen
2 participants