isogeo_pysdk.api.routes_feature_attributes module

Isogeo API v1 - API Routes for FeatureAttributes entities

See: http://help.isogeo.com/api/complete/index.html

class isogeo_pysdk.api.routes_feature_attributes.ApiFeatureAttribute(api_client=None)

Bases : object

Routes as methods of Isogeo API used to manipulate feature attributes into a Metadata.

create(metadata, attribute)

Add a new feature attribute to a metadata (= resource).

Paramètres:
  • metadata (Metadata) – metadata (resource) to edit

  • attribute (FeatureAttribute) – feature-attribute object to create

Renvoie:

409 if an attribute with the same name already exists.

Type renvoyé:

FeatureAttribute or tuple

Example:

>>> # retrieve metadata
>>> md = isogeo.metadata.get(METADATA_UUID)
>>> # create the attribute locally
>>> new_attribute = FeatureAttribute(
    alias="Code INSEE de la commune",
    name="INSEE_COM",
    description="Une commune nouvelle résultant d’un regroupement de communes "
    "préexistantes se voit attribuer  le  code  INSEE  de  l’ancienne  commune "
    "désignée  comme  chef-lieu  par  l’arrêté  préfectoral  qui  l’institue. "
    "En  conséquence  une  commune change  de  code  INSEE  si  un  arrêté "
    "préfectoral modifie son chef-lieu.",
    dataType="CharacterString (5)",
    language="fr",
    )
>>> # add it to the metadata
>>> isogeo.metadata.attributes.create(md, new_attribute)
delete(attribute, metadata=None)

Delete a feature-attribute from a metadata.

Paramètres:
  • attribute (FeatureAttribute) – FeatureAttribute model object to delete

  • metadata (Metadata) – parent metadata (resource) containing the feature-attribute

get(metadata_id, attribute_id)

Get details about a specific feature-attribute.

Paramètres:
  • metadata_id (str) – metadata UUID

  • attribute_id (str) – feature-attribute UUID

Example:

>>> # get a metadata
>>> md = isogeo.metadata.get(METADATA_UUID)
>>> # list all og its attributes
>>> md_attributes = isogeo.metadata.attributes.listing(md)
>>> # get the first attribute
>>> attribute = isogeo.metadata.attributes.get(
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~isogeo\_pysdk.models.feature\_attributes.FeatureAttribute\``
    metadata_id=md._id,
    attribute_id=md_attributes[0].get("_id")
    )
import_from_dataset(metadata_source, metadata_dest, mode='add', case_sensitive_matching=True)

Import feature-attributes from another vector (or DTNG) metadata.

Paramètres:
  • metadata_source (Metadata) – metadata from which to import the attributes

  • metadata_dest (Metadata) – metadata where to import the attributes

  • mode (str) – mode of import, defaults to “add”:

Type renvoyé:

bool - “add”: add the attributes except those with a duplicated name - “update”: update only the attributes with the same name - “update_or_add”: update the attributes with the same name or create

: param bool case_sensitive_matching: False to make feature attributes’s name matching case-insensitive when mode == « update »

Lève:
  • TypeError – if one metadata is not a vector or DTNG

  • ValueError – if mode is not one of accepted value

Example:

# get the metadata objects
md_source = isogeo.metadata.get(METADATA_UUID_SOURCE)
md_dest = isogeo.metadata.get(METADATA_UUID_DEST)

# launch import
isogeo.metadata.attributes.import_from_dataset(md_source, md_dest, "add")
listing(metadata)

Get all feature-attributes of a metadata.

Paramètres:

metadata (Metadata) – metadata (resource)

Type renvoyé:

list

update(attribute, metadata=None)

Update a feature-attribute.

Paramètres:
  • attribute (FeatureAttribute) – Feature Attribute model object to update

  • metadata (Metadata) – parent metadata (resource) containing the feature-attribute

Type renvoyé:

FeatureAttribute