django_website.Primitives package

Submodules

django_website.Primitives.GeoImage module

class django_website.Primitives.GeoImage.CustomJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Convenience class used to return JSON responses in the views.

default(o)[source]
class django_website.Primitives.GeoImage.GeoImage[source]

Bases: object

Object responsible for keeping image and panorama’s data

fields:
  • idstr

    Used to syncronize calls to the image filtering endpoint (see ImageFilter).

  • datastr

    Used to hold either the image from this location, (encoded as a base64 string) or an url to it.

  • dataTypestr

    Used to distinguish when data is a base64 string encoding an image or an url to it. dataType will be ‘URL’ in the latter case and ‘data:image/jpeg;base64’ otherwise.

  • location<geojson.Point>

    Represents the geographical location of this object. A <geojson.Point> is represented by its ‘coordinates’ property which are in turn a tuple with exactly 2 or 3 values.

  • headingfloat

    Represents the horizontal angle of the image. That is the azimuth, of some spherical coordinate system, of the camera in the moment that the picture was taken.

  • pitchfloat

    Represents the vertical angle of the image, that is the altitude of a spherical coordinate system, of the camera in the moment that the picture was taken.

  • metadatadict

    Represents data not directly related to the GeoImage but usefull for relating it to other GeoImages. For example, the metadata may contain information about other GeoImages in the same location, or perhaps the timestamp of when the picture was taken.

  • processedDataListdict[str, ProcessedImageData]

    Contains the list of ProcessedImageData objects related to this GeoImage. For example, after being processed by the GreeneryFilter class a GeoImage will contain as one of its processedDataList members the ‘greenery’ key to a ProcessedImageData containing the results of the greenery filter applied over this GeoImage.

classmethod fromJSON(jsonData: dict)[source]

Helper method used to instantiate a GeoImage from its JSON representation (encoded as a dict).

jsonData: dict

The dict representing the GeoImage to be instantiated.

A new instance of GeoImage

static imageToBase64JPEG(inputImage: <module 'PIL.Image' from '/usr/local/lib/python3.6/site-packages/PIL/Image.py'>)[source]

Used to encode a PIL Image into a base64 string.

inputImage: PIL.Image

The image to be encoded

A base64 encoded string representing the input image.

setProcessedData(filterId: str, type: str, imageData=None, density=-1, isPresent=None)[source]

Sets or updates a ProcessedData object (identified by its filterId) from the ProcessedDataDict

filterIdstr

Identifies the ProcessedData object with the id of the ImageFilter subclass used.

type: str

Defines the image format (‘ndarray’ or None)

imageData=None: Any

Image’s pixel data, defaults to None. But can be a Numpy.ndarray or a base64 string

density=-1: float

Defines how much of a feature is present in an image (eg. greenery), defaults to -1

isPresent=None: boolean

Defines if a feature exists in the image (eg. Poles), defaults to None

class django_website.Primitives.GeoImage.ProcessedImageData[source]

Bases: object

Represents the result object derived from some subclass of django_website.MapMiners.MapMiner.MapMiner.

fields:
  • id=Nonestr

    Representation of the geoImage used to referentiate it at the backend.

  • imageData=Nonestr

    A base64 encoded sting or an url to the actual image. Depends on the property imageDataType.

  • imageDataType=Nonestr

    data:image/jpeg;base64 if the imageData is base64 encoded URL if the imageData is a url to the actual image.

  • filterId=None: str

    The identification (filterId property) of the django_website.ImageFilters.ImageFilter.ImageFilter subclass used to generate this ProcessedImageData.

  • density=-1float

    This property can be used as a quantitative metric about the processed image (e.g. ammount of greenery in the processed image).

  • isPresent=Noneboolean

    This property can be used as a flag indicating the presence of some feature found in the processed image.

class django_website.Primitives.GeoImage.SimpleDTO[source]

Bases: object

Base class used to convert objects to JSON notation facilitating the communication between front and back ends.

toJSON(compact=True)[source]

Rewrites the instance as a JSON object

compact=Trueboolean

If true line-breaks and whitespaces will not be included.

str representation of the object

django_website.Primitives.GeoSampa module

class django_website.Primitives.GeoSampa.GeoSampa_BusStops(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Model class for GeoSampa Bus Stops Shapefile Source shapefile: SAD69-96_SHP_pontoonibus_point.shp Ref. URL: http://spatialreference.org/ref/epsg/sad69-utm-zone-23s/ ProjectionId: EPSG:29183

fields:
  • addressstr

    The address of the bus stop

  • descriptionstr

    Same as address, but eventually contains aditional details

  • namestr

    The bus stop name, a reference that can be used to search for the bus stop at the system of SPTrans.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

address

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

mpoint

GeoDjango-specific: a geometry field (PointField)

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>

django_website.Primitives.OSMPrimitives module

class django_website.Primitives.OSMPrimitives.OSM3S(timestamp_osm_base=None, copyright='')[source]

Bases: object

Timestamp and copyright info

DictToOSM3S()[source]

Parses an dict object into an OSM3S object

JsonToOSM3S()[source]

Parses an string to an OSM3S object

class django_website.Primitives.OSMPrimitives.OSMNode(id: int, type: str, lat: decimal.Decimal, lon: decimal.Decimal, tags={})[source]

Bases: django_website.Primitives.OSMPrimitives.OSMObject

Class used as an OpenStreetMap Node object wrapper

fields:
  • latDecimal

    Represents this OSMNode latitude

  • lonDecimal

    Represents this OSMNode longitude

  • tagsdict

    Each OSMNode, OSMWay and OSMRelation can contain an arbitratry number of tags, each of which corresponds to some attribute of that OSM object (e.g. an OSMNode could have a tag ‘highway’ with the value ‘traffic_signals’).

class django_website.Primitives.OSMPrimitives.OSMObject(id: int, type: str, tags={}, **kwargs)[source]

Bases: object

Base class for other OSM objects: Attribute Name: default value version: 0 visible: True timestamp: None changeset: 0 user: ‘’ #user’s name uid: 0 #user’s id

class django_website.Primitives.OSMPrimitives.OSMRelation(id: int, type, members: List[django_website.Primitives.OSMPrimitives.OSMObject], tags={})[source]

Bases: django_website.Primitives.OSMPrimitives.OSMObject

A OpenStreetMap relation represents ‘belongs to’ relations (i.e. OSMNode objects belonging to the same OSMWay or a collection of OSMWay objects that belongs to the same OSMRelation which represets for example the boundaries of some region.)

fields:
  • idint

    Represents the relation id as informed by OpenStreetMap database

  • typestr

    It can be anything for example ‘boundary’.

  • membersList[OSMObject]

    An OSMRelation can be composed by any number and type of objects (e.g. an OSMRelation with type ‘route’ can contain different OSMWays that compose the route of a bus).

class django_website.Primitives.OSMPrimitives.OSMRelationMember(type, ref, role)[source]

Bases: object

An element that ‘belogs’ to another (i.e. An OSMNode that belongs to an OSMWay)

class django_website.Primitives.OSMPrimitives.OSMResult(version: float, generator: str, osm3s: django_website.Primitives.OSMPrimitives.OSM3S, elements: list = [])[source]

Bases: object

Represents a query result to an OpenStreetMap server

fromJsonDict()[source]

Parses a dict into a OSMResult

fromJsonString()[source]

Parses a json string into a OSMResult object

class django_website.Primitives.OSMPrimitives.OSMWay(id: int, type, nodes: List[int], tags={})[source]

Bases: django_website.Primitives.OSMPrimitives.OSMObject

Class used as an OpenStreetMap Way object wrapper. In this abstraction an OSMWay is only considered to be a set of nodes contained in the field nodes.

fields:
  • nodesList[int]

    The set of nodes contained in this OSMWay. An OSMWay is used to represent usually linear features such as avenues and streets.

  • tagsdict

    See tags in OSMNode

Module contents

These module contains classes used primarily as DTOs (data transfer objects), that is, an object just with properties.