Skip to content

Up down loader option in the Design module

rajatSinha303 edited this page Sep 21, 2018 · 42 revisions

The up/down-loader option adds methods to upload and download data to and from the design module layers. There are 2 formats supported: shape and excel files.

Shape files

Shape files are supported with 3 geometries: dots, lines and polygons.

  • Dots are represented as circles that have a constant diameter, regardless of the zoom level of the map the circles are shown with the same dimensions and do not scale. The circles can have 2 colors: the outline and the fill can be determined via a color palette.
  • Lines can be made of multiple line segments. The coloring of the lines is determined via a color palette.
  • Polygons are build up by a closed line (the last point of the line is the same location as the starting point of the line). The closed line is drawn in the outline color defined by a color palette and filled with the fill color defined by that same color palette.

The data fields in a shape file are limited to 10 characters. Because the field names are used to create or link to data fields of the table in the ecodistrict database it is important when using shape files in uploading data to initially create the fields with short names no longer then 10 characters. If longer names are used, downloaded shapes with fields trimmed to 10 characters cannot be uploaded again because of the mismatch in field names.

Excel files

Downloaded Excel files contain all fields available in the table that have known types. The first row of the Excel file will contain field names and type to help parse the data to import into the database. Special codes are used to remove fields and/or rows from the data. The file type is called Excel because it is in an export format of Excel. The format is the text-export from Excel with a tab character as a field delimiter. Excel can directly open, save and work with this format. Floating point numbers should be exported in the US format: a dot as decimal separator, it can be in normal x.xxxx format or in scientific format x.xxe+xx.

Field types and names

Type Description
int Integer types can hold whole numbers such as 123 and −56.
float Floating point data types are used to represent numbers with a fractional part.
String String type is used to represent textual data.
boolean Boolean represents a logical entity and can have two values: true, and false.
GUIDs GUIDs are large, enormous numbers that are nearly guaranteed to be unique.
timeStamps The timeStamps data type is used for values that contain both date and time parts.
geometry The geometry type represents data in JSON format.

Uploading files

To upload a file, hover on the upload/download control button present at the bottom-left of the screen (Collapsed state).

When the mouse is hovered upon the control button, the complete upload/download control is displayed (Expanded State).

Collapsed state Expanded state
Collapsed state Expanded State

There are two ways to upload a file:

  • Drag and drop a file over the upload/download control.

  • Click on the Choose Files button in the upload/download control.

    • On clicking on the Choose Files button, a dialogue box is displayed for the user to select the file(s) for uploading.

    upload/download choose file dialogue

The name of the file to be uploaded should follow the following set of rules:

  • Completely in lowercase.
  • No spaces allowed.
  • No special characters allowed.

The field names of the data entries in the shapefiles should follow the following set of rules:

  • Completely in lowercase.
  • No spaces allowed.
  • No special characters other than underscore ( _ ) are allowed.

Shape files

  • To upload the shapefiles, compress (ZIP) the collection of files (.shp, .shx, .dbf, etc) and then use the compressed (.zip) file for uploading.
  • A projection file (.prj) can also be added to the collection of files while compressing.

Excel file

  • To use an excel file for uploading the data, following set of rules need to be followed while creating the file:
    • There should be no empty cells in between.
    • The first line should contain the following information - <FieldName>:<Type>.
      • <FieldName> - This represents the column name.
      • <Type> - This can be set to any of the supported types.
    • Geometry data should always be in the latitude & longitude format.

On successfully uploading the file (shapefiles or excel), the filename is used as the table name in the database.

  • If a table with the provided filename does not exist, a new table is created.
  • If a table with the provided filename exists, the data from the uploaded files is inserted into the table.
    • MORE INFORMATION NEEDED HERE

Next, the primary key for the table needs to be defined (preferably a field containing integer values).

  • If a field name in the uploaded file is - ID, this field will be considered as the primary key in the database table.
  • If no such fields are found, then any field name containing the substring - ID will be considered as the primary key.
  • If neither of the above cases are true, the first field will be considered as the primary key.

Color palettes

There are 2 types of legends that can be derived from given palettes. The palette is defined in JSON, with some extra information a legend can automatically be derived from this.

  • Discrete legend: discrete steps or levels with specified colors.
  • Ramp color legend: gradients between values.

Definition of a legend in JSON

    color = [<red>, <green>, <blue>, <alpha>] | "#<rr><bb><gg><aa>" | "#<r><b><g><a>" | "#<rr><bb><gg>" | "#<r><b><g>"

Where red, green, blue are [0..255], alpha is [0.0..1.0] (default=1.0=opaque)

	geoColor = { 
		"fill": <color>(default=[0, 0, 0, 255]),
		"outline": <color>(default=[0, 0, 0, 0]),
		"fill2": <color>(default=[0, 0, 0, 0])
	}

	legend common: {
		"type": "discrete"(default)|"ramp",
		"description": <string>,
		"entries": []
	}

	discreteEntry: {
		"color": <geoColor>,
		"minValue": <double>,
		"maxValue": <double> (default=<minValue>+1), 
		"description": <string>(default="")
	}

	discrete: {
		"orientationVertical": true(default)|false
		"noDataColor": <geoColor>(default={fill: [0, 0, 0, 255]})
		"entries": [<discreteEntry>[,<discreteEntry>]]
	}

	rampEntry: {
		"color": <color>,
		"value": <double>,
		"description": <string>(default=<value-as-string>
	}

	ramp: {
		"lowerDataColor": <color>(default=[0, 0, 0, 255]), color used when value is lower then lowest defined range
		"noDataColor": <color>(default=[0, 0, 0, 255]), color used when value is NaN or null
		"higherDataColor": <color>(default=[0, 0, 0, 255]), color used when value is higher then lowest defined range
		"width": <int>(default=300),
		"logScale": false(default)| true,
		"tickFontSize": <int>(default=11),
		"entries": [<rampEntry>[,<rampEntry>]]
	}

Clone this wiki locally