Repository navigation
Up down loader option in the Design module
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 Text/Excel files.
An extra option id added to control the visualisation through the up/down-load of layer 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. They 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.
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.
| Type | Description |
|---|---|
| integer | 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. |
| text | Text type is used to represent textual data. |
| boolean | Boolean represents a logical entity and can have two values: true, and false. |
| guid/uuid | GUIDs are large, enormous numbers that are nearly guaranteed to be unique. |
| timestamp | The timeStamps data type is used for values that contain both date and time parts. |
| geometry | The geometry type represents data in JSON format. |
| money | Used for currency. |
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 |
There are two ways to upload a file:
-
Drag and drop a file over the upload/download control.
-
Click on the
Choose Filesbutton in the upload/download control.- On clicking on the
Choose Filesbutton, a dialogue box is displayed for the user to select the file(s) for uploading.
- On clicking on the
The name of the file to be uploaded should follow the following set of rules:
- Simple and explaining the type of data
- Completely in lowercase.
- No spaces allowed.
- No special characters allowed.
The field names of the data entries in the file to be uploaded should follow the following set of rules:
- Completely in lowercase.
- No spaces allowed.
- No special characters other than underscore ( _ ) are allowed.
- 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.
- 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 rows.
- There should be no empty cells in between.
- The first line should contain the following column header 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.
- For an existing table, if the uploaded file contains rows with row-ids that exist in the original table, the new values are overwritten over the old row values.
- For an existing table, if the uploaded file contains new rows (rows with IDs not existing in the original table), the new rows are appended to the table.
- For an existing table, if the uploaded file contains new columns, the new columns are added to the table.
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 -
IDwill be considered as the primary key. - If neither of the above cases are true, the first field will be considered as the primary key.
Only files with .Txt and .zip (only files with .shp extension inside the zip folder) are allowed to be uploaded. In case of files with other extensions, it will show en error log in the browser as shown below.
On hovering over the upload/download control, we see the expanded control.
In here we see a download section with a list of files available for download.
We can either download a shapefile ,text file (excel sheet) or a JSON file with "layers" header. To download, click on 'shape' , 'text' or 'layer' to start the download process.
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)
{
"layers":
[
{
"sql":"",
"description":"trialnew code",
"domain":"domain",
"id":"trialnew_code",
"palettejson":
{
"entries":
[
{
"value":6101,
"color":"#ffeeee",
"description":"low"
},
{
"value":6101,
"color":"#ff0000",
"description":"high"
}
],
"lowerDataColor":"#ffeeee",
"description":"trialnew code",
"type":"ramp",
"higherDataColor":"#ff0000",
"noDataColor":"#000000"
},
"name":"code",
"basiclayer":0,
"legendjson":null,
"datafieldname":"code",
"statistics":
{
"max":6101,
"avg":6101,
"min":6101
},
"defaultload":0
}
]
}