Skip to content

Commit

Permalink
Add Ukraine Map
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarovS96 committed Jul 6, 2018
1 parent 70418ec commit 032cdf3
Show file tree
Hide file tree
Showing 9 changed files with 10,721 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cls/DSWMap/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class DSWMap.Utils
ClassMethod SetupAll()
{

for map="CZ","FIN","RSA","SE","RF.SAKH","RF.KHAB","USA","UK","KZ" {
for map="CZ","FIN","RSA","SE","RF.SAKH","RF.KHAB","USA","UK","KZ","UA" {
do $CLASSMETHOD(map_".Utils", "Setup")
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/cls/UA/Area.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class UA.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>^UA.AreaD</DataLocation>
<DefaultData>AreaDefaultData</DefaultData>
<IdLocation>^UA.AreaD</IdLocation>
<IndexLocation>^UA.AreaI</IndexLocation>
<StreamLocation>^UA.AreaS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

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

/// Cube definition from Architect.
XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
{
<cube xmlns="http://www.intersystems.com/deepsee" name="UACube" displayName="UACube" disabled="false" abstract="false" sourceClass="UA.Region" countMeasureName="%COUNT" bucketSize="8" bitmapChunkInMemory="false" precompute="0" disableListingGroups="false">
<dimension name="ParentRegion" disabled="false" hasAll="false" allCaption="All ParentRegion" allDisplayName="ParentRegion" type="data" hidden="false" showHierarchies="default">
<hierarchy name="H1" disabled="false" hidden="false">
<level name="Region" disabled="false" sourceProperty="ParentRegion" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
<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="District" disabled="false" sourceProperty="Guid" list="false" useDisplayValue="true" useAsFilter="true" hidden="false">
<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(UA.Region).%OpenId(guid)
if $IsObject(region) {
s parameter=##class(UA.ParameterValue).RegionParameterIndexOpen(region.Guid,type)
if $IsObject(parameter) return parameter.Value}
return ""
}

Parameter DOMAIN;

}

32 changes: 32 additions & 0 deletions src/cls/UA/Parameter.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Class UA.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>^UA.ParameterD</DataLocation>
<DefaultData>ParameterDefaultData</DefaultData>
<IdLocation>^UA.ParameterD</IdLocation>
<IndexLocation>^UA.ParameterI</IndexLocation>
<StreamLocation>^UA.ParameterS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

42 changes: 42 additions & 0 deletions src/cls/UA/ParameterValue.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Class UA.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>^UA.ParameterValueD</DataLocation>
<DefaultData>ParameterValueDefaultData</DefaultData>
<IdLocation>^UA.ParameterValueD</IdLocation>
<IndexLocation>^UA.ParameterValueI</IndexLocation>
<StreamLocation>^UA.ParameterValueS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}

25 changes: 25 additions & 0 deletions src/cls/UA/Region.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Class UA.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 032cdf3

Please sign in to comment.