~dhis2-devs-core/dhis2/2.6

« back to all changes in this revision

Viewing changes to dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java

  • Committer: Lars Helge Overland
  • Date: 2012-02-07 16:20:14 UTC
  • Revision ID: larshelge@gmail.com-20120207162014-j0rajl9fwgsmlupg
R 5875, 5876

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        // Build internal map layer representation
88
88
        InternalMapLayer mapLayer = buildSingleInternalMapLayer( mapView );
89
89
 
 
90
        if ( mapLayer == null )
 
91
        {
 
92
            return null;
 
93
        }
 
94
        
90
95
        // Build internal representation of a map using GeoTools, then render it
91
96
        // to an image
92
97
        GeoToolsMap gtMap = new GeoToolsMap( mapLayer );
127
132
 
128
133
        boolean isIndicator = MappingService.MAP_VALUE_TYPE_INDICATOR.equals( mapView.getMapValueType() );
129
134
 
 
135
        Collection<AggregatedMapValue> mapValues;
 
136
        
 
137
        if ( isIndicator )
 
138
        {
 
139
            mapValues = mappingService.getIndicatorMapValues( mapView.getIndicator().getId(), mapView.getPeriod()
 
140
                .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
 
141
        }
 
142
        else
 
143
        {
 
144
            mapValues = mappingService.getDataElementMapValues( mapView.getDataElement().getId(), mapView.getPeriod()
 
145
                .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
 
146
        }
 
147
        
 
148
        if ( !( mapValues != null && mapValues.size() > 0 ) )
 
149
        {
 
150
            return null;
 
151
        }
 
152
        
130
153
        // Get the name from the external layer
131
154
        String name = mapView.getName();
132
155
 
165
188
        mapLayer.setStrokeColor( strokeColor );
166
189
        mapLayer.setStrokeWidth( strokeWidth );
167
190
 
168
 
        // Get the aggregated map values
169
 
        // TODO Might make version of getIndicatorMapValues that takes Indicator
170
 
        // and parent OrganisationUnit *directly*, i.e. not from ID-s, since we have
171
 
        // them
172
 
        // NOTE There is no need to provide startDate and endDate as period is
173
 
        // set
174
 
        Collection<AggregatedMapValue> mapValues;
175
 
        
176
 
        if ( isIndicator )
177
 
        {
178
 
            mapValues = mappingService.getIndicatorMapValues( mapView.getIndicator().getId(), mapView.getPeriod()
179
 
                .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
180
 
        }
181
 
        else
182
 
        {
183
 
            mapValues = mappingService.getDataElementMapValues( mapView.getDataElement().getId(), mapView.getPeriod()
184
 
                .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
185
 
        }
186
 
        
187
191
        // Build and set the internal GeoTools map objects for the layer
188
192
        buildGeoToolsMapObjectsForMapLayer( mapLayer, mapValues );
189
193