Skip to content

Commit

Permalink
[ADD] Map of United Kingdom
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarovS96 committed Oct 9, 2017
1 parent 914bfbb commit d937a13
Show file tree
Hide file tree
Showing 9 changed files with 1,644 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/cls/UK/Area.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class UK.Area Extends (%Persistent, %XML.Adaptor)
{

/// Name of the Region
Property Name As %String(MAXLEN = 500) [ Required ];

/// Guid for polygons in js file
Property Guid As %String [ Required ];

/// Link to Wiki article
Property DataUrl As %String(MAXLEN = 500);

/// All values
Relationship Parameters As ParameterValue [ Cardinality = many, Inverse = Region ];

Index GuidIdx On Guid [ IdKey, Unique ];

Storage Default
{
<Data name="AreaDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>DataUrl</Value>
</Value>
</Data>
<DataLocation>^UK.AreaD</DataLocation>
<DefaultData>AreaDefaultData</DefaultData>
<IdLocation>^UK.AreaD</IdLocation>
<IndexLocation>^UK.AreaI</IndexLocation>
<StreamLocation>^UK.AreaS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

64 changes: 64 additions & 0 deletions src/cls/UK/BI/UKCube.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
///
Class UK.BI.UKCube Extends %DeepSee.CubeDefinition [ DependsOn = SE.Region, ProcedureBlock ]
{

/// Cube definition from Architect.
XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
{
<cube xmlns="http://www.intersystems.com/deepsee" name="UKCube" displayName="UKCube" disabled="false" abstract="false" sourceClass="UK.Region" countMeasureName="%COUNT" bucketSize="8" bitmapChunkInMemory="false" precompute="0" disableListingGroups="false">
<dimension name="Region" disabled="false" hasAll="false" allCaption="All ParentRegion" allDisplayName="ParentRegion" type="data" calendar="gregorian" iKnowType="entity" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false">
<level name="Province" disabled="false" sourceProperty="ParentRegion" list="false" useDisplayValue="true" useAsFilter="true">
<property name="Color" disabled="false" sourceExpression="&quot;rgb(0,255,0)&quot;" hidden="false" isName="false" isDescription="false" isReference="false" useDisplayValue="false"></property>
<property name="Population" disabled="false" sourceExpression="%cube.GetValue(%source.ParentRegion.Guid,1)" hidden="false" isName="false" isDescription="false" isReference="false" useDisplayValue="false"></property>
<property name="Area" disabled="false" sourceExpression="%cube.GetValue(%source.ParentRegion.Guid,2)" hidden="false" isName="false" isDescription="false" isReference="false" useDisplayValue="false"></property>
<property name="Name" disabled="false" sourceProperty="ParentRegion.Name" hidden="false" isName="true" isDescription="false" isReference="false" useDisplayValue="false"></property>
</level>
<level name="Municipality" disabled="false" sourceProperty="Guid" list="false" useDisplayValue="true" useAsFilter="true">
<property name="Population" disabled="false" sourceExpression="%cube.GetValue(%source.Guid,1)" hidden="false" isName="false" isDescription="false" isReference="false" useDisplayValue="false"></property>
<property name="Area" disabled="false" sourceExpression="%cube.GetValue(%source.Guid,2)" hidden="false" isName="false" isDescription="false" isReference="false" useDisplayValue="false"></property>
<property name="Name" disabled="false" sourceProperty="Name" hidden="false" isName="true" isDescription="false" isReference="false" useDisplayValue="false"></property>
</level>
</hierarchy>
</dimension>
<listing name="New_listing1" disabled="false" listingType="table" fieldList="%ID,DataUrl,Name,ParentRegion-&gt;Guid,ParentRegion-&gt;Name"></listing>
</cube>
}

ClassMethod GetColor(min, max, value) As %String
{
if ('value) return "rgb(0,0,0)"

// Крайние границы: красный и зеленый, цвет для середины - желтый
set middle = (max + min) / 2

if (value <= middle)
{
set redPart = (value - min) / (middle - min)
return "rgb(" _ (255 * redPart\1) _ ",255, 0)"
}
else
{
set greenPart = (max - value) / (max - middle)
return "rgb(255," _(255 * greenPart\1) _ ", 0)"
}
}

ClassMethod GetValue(guid, type) As %Integer
{

//b "L"
//type=1 - population
//type=2 - area
// density
s region=##class(UK.Region).%OpenId(guid)
if $IsObject(region) {
s parameter=##class(UK.ParameterValue).RegionParameterIndexOpen(region.Guid,type)
if $IsObject(parameter) return parameter.Value}
return ""
}

Parameter DOMAIN;

}

32 changes: 32 additions & 0 deletions src/cls/UK/Parameter.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class UK.Parameter Extends (%Persistent, %XML.Adaptor)
{

Property Name As %String;

Property UnitName As %String;

Relationship Values As ParameterValue [ Cardinality = many, Inverse = Parameter ];

Storage Default
{
<Data name="ParameterDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>UnitName</Value>
</Value>
</Data>
<DataLocation>^UK.ParameterD</DataLocation>
<DefaultData>ParameterDefaultData</DefaultData>
<IdLocation>^UK.ParameterD</IdLocation>
<IndexLocation>^UK.ParameterI</IndexLocation>
<StreamLocation>^UK.ParameterS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

42 changes: 42 additions & 0 deletions src/cls/UK/ParameterValue.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Class UK.ParameterValue Extends (%Persistent, %XML.Adaptor)
{

Relationship Region As Area(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = Parameters ];

/// State, county or city
/// Parameter
Relationship Parameter As Parameter(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = Values ];

/// Value for region|county|city
Property Value As %Float [ Required ];

Index PVIdx On (Region, Parameter);

Index RegionParameterIndex On (Region, Parameter) [ Unique ];

Storage Default
{
<Data name="ParameterValueDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Region</Value>
</Value>
<Value name="3">
<Value>Parameter</Value>
</Value>
<Value name="4">
<Value>Value</Value>
</Value>
</Data>
<DataLocation>^UK.ParameterValueD</DataLocation>
<DefaultData>ParameterValueDefaultData</DefaultData>
<IdLocation>^UK.ParameterValueD</IdLocation>
<IndexLocation>^UK.ParameterValueI</IndexLocation>
<StreamLocation>^UK.ParameterValueS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

25 changes: 25 additions & 0 deletions src/cls/UK/Region.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Class UK.Region Extends Area
{

/// Parent of region. For state=null, for county=state
Relationship ParentRegion As Region(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = ChildrenRegions ];

/// Region childrens. For state=counties, for county=0
Relationship ChildrenRegions As Region [ Cardinality = many, Inverse = ParentRegion ];

Index ParentRegionIdx On ParentRegion;

Storage Default
{
<Data name="RegionDefaultData">
<Subscript>"Region"</Subscript>
<Value name="1">
<Value>ParentRegion</Value>
</Value>
</Data>
<DefaultData>RegionDefaultData</DefaultData>
<Type>%Library.CacheStorage</Type>
}

}

Loading

0 comments on commit d937a13

Please sign in to comment.