// mouseMove
//---------------------------------------------------------------------------
void VehicleSelectionView::mouseMove(const iXY &prevPos, const iXY &newPos)
{
    GameTemplateView::mouseMove(prevPos, newPos);

    if ( highlightedUnitType >= 0 )
    {
        char strBuf[256];
        int rtime = getUnitRegenTime(highlightedUnitType);
        snprintf(strBuf, sizeof(strBuf)-1, "%s - %s: %01d:%02d",
                 getUnitName(highlightedUnitType),
                 _("Build Time"),
                 rtime / 60, rtime % 60);
//        statusBar->setText(strBuf);
    }
    else
    {
//        statusBar->setText(_("Select a unit for production"));
    }

} // end VehicleSelectionView::mouseMove
// drawMiniProductionStatus
//---------------------------------------------------------------------------
void VehicleSelectionView::drawMiniProductionStatus(Surface &dest)
{
    char strBuf[256];
    char outpostNameBuf[256];
    char outpostUserNameBuf[256];
    char productionUnitBuf[256];
    char timeLeftBuf[256];

    iRect         gameViewRect;

    WorldViewInterface::getViewWindow(&gameViewRect);

    ObjectiveID objective_id;

    Objective* obj;
    ObjectiveID max_objective = ObjectiveInterface::getObjectiveCount();

    for ( objective_id = 0; objective_id < max_objective; ++objective_id)
    {
        obj = ObjectiveInterface::getObjective( objective_id );

        bool owned = obj->occupying_player && obj->occupying_player == PlayerInterface::getLocalPlayer();

        if ( ! displayOutpostNames && ( ! owned || ! displayMiniProductionStatus ) )
        {
            continue;
        }

        // @todo set the correct view location
//        miniProductionRect.setLocation(obj->area.getAbsRect(obj->location).getLocation() - gameViewRect.getLocation());
        miniProductionRect.setSize(140, owned ? 50: 20);
        if ( obj->occupying_player ) 
        {
            miniProductionRect.translate(0, -16);
            int length = strlen( obj->occupying_player->getName().c_str() );
            if (length > 13)
            {
                strncpy(strBuf, obj->occupying_player->getName().c_str() , 10);
                strBuf[10] = 0; // fix runners
                sprintf(outpostUserNameBuf, "%s:  %s...", _("Owner"),  strBuf);
            }
            else
            {
                sprintf(outpostUserNameBuf, "%s:  %s", _("Owner"), obj->occupying_player->getName().c_str() );
            }
        }
        iXY pos(miniProductionRect.getLocation());
        pos.x += 4;
        pos.y += 4;

        // Make sure the name will fit reasonably in the area.
        int length = strlen( obj->name );
        if (length > 10)
        {
            strncpy(strBuf, (const char *) obj->name , 7);
            strBuf[7] = 0; // fix runners
            sprintf(outpostNameBuf, "%s:  %s...", _("Outpost"),  strBuf);
        }
        else
        {
            sprintf(outpostNameBuf, "%s:  %s", _("Outpost"), (const char *) obj->name );
        }
        checkMiniProductionRect(outpostNameBuf);

        if ( owned )
        {
            if ( ! obj->unit_generation_on_flag )
            {
                // Objective is off.
//                dest.bltLookup(miniProductionRect, Palette::filterDarkGray());
                dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan);
                pos.y += 16;
                dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
                pos.y += 16;
                dest.bltString(pos.x, pos.y, _("Production Off"), Color::white);
            }
            else
            {
                // Objective is on.

                sprintf(productionUnitBuf, _("Production: %s"), getUnitName(obj->unit_generation_type));
                checkMiniProductionRect(productionUnitBuf);

                float tleft = obj->unit_generation_timer.getTimeLeft();
                sprintf(timeLeftBuf, "%s:  %01d:%02d", _("Time Left"),
                        ((int)tleft) / 60,
                        ((int)tleft) % 60);
                checkMiniProductionRect(timeLeftBuf);
//                dest.bltLookup(miniProductionRect, Palette::filterDarkGray());

                dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan);
                pos.x += unitImages[0]->getWidth();
                pos.y += 16;
                dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
                pos.y += 16;
                dest.bltString(pos.x, pos.y, productionUnitBuf, Color::white);
                pos.y += 16;
                dest.bltString(pos.x, pos.y, timeLeftBuf, Color::white);
                pos.y += 16;

                // Draw the current production unit image.
                drawUnitImage(dest, miniProductionRect.getLocation() + iXY(1,16), obj->unit_generation_type);
            }
        }
        else
        {
//            dest.bltLookup(miniProductionRect, Palette::filterDarkGray());
            if ( obj->occupying_player) 
            {
                dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan);
                pos.y += 16;
            }
            dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
        }
    }

} // end VehicleSelectionView::drawMiniProductionStatus
// doDraw
//--------------------------------------------------------------------------
void VehicleSelectionView::doDraw( Surface& dest )
{
    Objective* obj = ObjectiveInterface::getObjective(CURRENT_SELECTED_OUTPOST_ID);
    if ( !obj || obj->occupying_player != PlayerInterface::getLocalPlayer() )
    {
//        Desktop::setVisibilityNoDoAnything("VehicleSelectionView", false);
        changeMade = false;
        return;
    }
    
    char strBuf[256];

    const int color = Color::white;

    // Draw a line attaching the VehicleSelectionView to its outpost.
    {if (WorldInputCmdProcessor::isObjectiveSelected())
        {
            // Draw a line connecting the vehicleSelectionView and the objective.
            iRect gameViewRect;
            WorldViewInterface::getViewWindow(&gameViewRect);

            iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos());
            objectivePos -= gameViewRect.getLocation();

            iXY a(VehicleSelectionView::getLocation() + VehicleSelectionView::getSize() / 2);
            iXY b(objectivePos);

            // Calculate the starting point on the outside of the vehicleSelectionView box.
            fXY v2oSlope(Math::unitDirection(a, b));

            a.x += int(v2oSlope.x * float(VehicleSelectionView::getWidth() / 2));
            a.y += int(v2oSlope.y * float(VehicleSelectionView::getHeight() / 2));

            // Calculate the starting point on the outside of the objective box.
            iXY objectiveOutlineSize(3, 3);

            //fXY o2vSlope(Math::unitDirection(b, a));

            //b.x += o2vSlope.x * float(objectiveOutlineSize.x);
            //b.y += o2vSlope.y * float(objectiveOutlineSize.y);

            //screen.drawLine(a, b, Color::white);

            iRect r(objectivePos.x - objectiveOutlineSize.x,
                    objectivePos.y - objectiveOutlineSize.y,
                    objectiveOutlineSize.x,
                    objectiveOutlineSize.y);

            screen->fillRect(r, Color::white);

            //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2;

            //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black);

            iXY oos(objectiveOutlineSize);
            iXY cpos;

            if (v2oSlope.x > 0 && v2oSlope.y > 0) {
                cpos = iXY(getEndX(), getEndY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x > 0 && v2oSlope.y <= 0) {
                cpos = iXY(getEndX(), getLocationY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y > 0) {
                cpos = iXY(getLocationX(), getEndY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y <= 0) {
                cpos = iXY(getLocationX(), getLocationY());
                r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y);
            }
//
            screen->drawLine(cpos, b, Color::white);
            screen->fillRect(r, Color::white);

            //screen.bltLookup(r, Palette::darkGray256.getColorArray());
            //screen.drawButtonBorder(r, Color::white, Color::gray96);

            // Draw the name of the outpost.
        }}

    bltViewBackground(dest);

    int remaining_time = 0;
    int generation_time = 0;

    if ( obj->unit_generation_on_flag )
    {
        remaining_time = obj->unit_generation_timer.getTimeLeft();
        UnitProfile* profile = UnitProfileInterface::getUnitProfile(obj->unit_generation_type);
        generation_time = profile->regen_time;
    }

    if (vsvUnitGenOn)
    {
        sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit));
        dest.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);

        sprintf(strBuf, "%01d:%02d/%01d:%02d",
                        remaining_time / 60, remaining_time % 60,
                        generation_time / 60, generation_time % 60);
         
        dest.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    }
    else
    {
        sprintf(strBuf, "%s", _("power off"));
        dest.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);
        dest.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    }

    int unitPerPlayer = GameConfig::game_maxunits / GameConfig::game_maxplayers;
    sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer);
    dest.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color);

    drawUnitProfileInfo(dest, iXY(0, unitProfileDataY), highlightedUnitType);

    //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 );
    //clientArea.bltString(timeRemainingPos, strBuf, color);

    View::doDraw( dest );

} // end VehicleSelectionView::doDraw
// drawMiniProductionStatus
//---------------------------------------------------------------------------
void VehicleSelectionView::drawMiniProductionStatus(Surface &dest)
{
    iRect         objectiveBounds;
    unsigned char objectiveOwner;
    iRect         gameViewRect;
    OutpostStatus outpostStatus;
    int           objectiveID = 0;

    WorldViewInterface::getViewWindow(&gameViewRect);
    ObjectiveInterface::startObjectivePositionEnumeration();

    while(ObjectiveInterface::objectivePositionEnumeration(&objectiveBounds, &objectiveOwner, &objectiveID )) {
        char strBuf[256];
        char outpostNameBuf[256];
        char productionUnitBuf[256];
        char timeLeftBuf[256];
        ObjectiveState *objective_state;

        objective_state = ObjectiveInterface::getObjectiveState( objectiveID );

        switch(objectiveOwner) {
            //break;

        case _objective_disposition_player: {

                iXY objectiveScreenPos(objectiveBounds.min - gameViewRect.min);

                outpostStatus = ObjectiveInterface::getOutpostStatus(objectiveID);

                assert(screen->getDoesExist());

                miniProductionRect.min   = objectiveScreenPos;
                miniProductionRect.max.x = 0;
                miniProductionRect.max.y = miniProductionRect.min.y + 50;

                if (!displayMiniProductionStatus && !displayOutpostNames) {
                    return;
                }

                if (!outpostStatus.unit_generation_on_off) {
                    miniProductionRect.max.x = miniProductionRect.min.x + 140;

                    iXY pos;

                    pos.x = miniProductionRect.min.x + 4;
                    pos.y = miniProductionRect.min.y + 4;


                    // Make sure the name will fit reasonably in the area.
                    int length = strlen( objective_state->name );
                    if (length > 20) {
                        strncpy(strBuf, (const char *) objective_state->name , 20);
                        sprintf(outpostNameBuf, "Outpost:    %s...", strBuf);

                    } else {
                        sprintf(outpostNameBuf, "Outpost:    %s", (const char *) objective_state->name );
                    }
                    checkMiniProductionRect(outpostNameBuf);


                    //pos.x = (miniProductionRect.getSizeX() - strlen("Production Off") * CHAR_XPIX) / 2 + miniProductionRect.min.x;
                    //pos.y = (miniProductionRect.getSizeY() - CHAR_YPIX) / 2 + miniProductionRect.min.y;

                    // Objective is off.
                    dest.bltLookup(miniProductionRect, Palette::darkGray256.getColorArray());

                    dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
                    pos.y += 16;
                    dest.bltString(pos.x, pos.y, "Production Off", Color::white);

                } else {
                    // Objective is on.

                    iXY pos;
                    pos.x = miniProductionRect.min.x + unitImages.getWidth() + 4;
                    pos.y = miniProductionRect.min.y + 4;

                    // Make sure the name will fit reasonably in the area.
                    int length = strlen( objective_state->name );
                    if (length > 20) {
                        strncpy(strBuf, (const char *) objective_state->name , 20);
                        sprintf(outpostNameBuf, "Outpost:    %s...", strBuf);

                    } else {
                        sprintf(outpostNameBuf, "Outpost:    %s", (const char *) objective_state->name );
                    }
                    checkMiniProductionRect(outpostNameBuf);

                    sprintf(productionUnitBuf, "Production: %s",
                            getUnitName(outpostStatus.unit_generation_type));
                    checkMiniProductionRect(productionUnitBuf);

                    sprintf(timeLeftBuf, "Time Left:  %01d:%02d",
                            ((int)outpostStatus.unit_generation_time_remaining)
                                / 60,
                            ((int)outpostStatus.unit_generation_time_remaining)
                                % 60);
                    checkMiniProductionRect(timeLeftBuf);

                    dest.bltLookup(miniProductionRect,
                            Palette::darkGray256.getColorArray());

                    dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
                    pos.y += 16;
                    dest.bltString(pos.x, pos.y, productionUnitBuf, Color::white);
                    pos.y += 16;
                    dest.bltString(pos.x, pos.y, timeLeftBuf, Color::white);
                    pos.y += 16;

                    // Draw the current production unit image.
                    drawUnitImage(dest, miniProductionRect.min + iXY(1,1), outpostStatus.unit_generation_type);
                }

                //vsvUnitGenOn    = outpost_status.unit_generation_on_off;

            }
            break;

        case _objective_disposition_allie :
        case _objective_disposition_enemy :
        case _objective_disposition_unoccupied : {
                if( displayOutpostNames == true ) {
                    iXY objectiveScreenPos(objectiveBounds.min - gameViewRect.min);

                    assert(screen->getDoesExist());

                    miniProductionRect.min   = objectiveScreenPos;
                    miniProductionRect.max.x = 0;
                    miniProductionRect.max.y = miniProductionRect.min.y + 20;

                    miniProductionRect.max.x = miniProductionRect.min.x + 140;

                    iXY pos;

                    pos.x = miniProductionRect.min.x + 4;
                    pos.y = miniProductionRect.min.y + 4;


                    // Make sure the name will fit reasonably in the area.
                    int length = strlen( objective_state->name );
                    if (length > 20) {
                        strncpy(strBuf, (const char *) objective_state->name , 20);
                        sprintf(outpostNameBuf, "Outpost:    %s...", strBuf);

                    } else {
                        sprintf(outpostNameBuf, "Outpost:    %s", (const char *) objective_state->name );
                    }
                    checkMiniProductionRect(outpostNameBuf);

                    dest.bltLookup(miniProductionRect, Palette::darkGray256.getColorArray());

                    dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white);
                }
            }
            break;

        }

    }

} // end VehicleSelectionView::drawMiniProductionStatus
// doDraw
//--------------------------------------------------------------------------
void VehicleSelectionView::doDraw(Surface &viewArea, Surface &clientArea)
{
    char strBuf[256];

    const int color = Color::white;

    // Draw a line attaching the VehicleSelectionView to its outpost.
    {if (WorldInputCmdProcessor::isObjectiveSelected())
        {
            // Draw a line connecting the vehicleSelectionView and the objective.
            iRect gameViewRect;
            WorldViewInterface::getViewWindow(&gameViewRect);

            iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos());
            objectivePos -= gameViewRect.min;

            iXY a(VehicleSelectionView::min + VehicleSelectionView::getSize() / 2);
            iXY b(objectivePos);

            // Calculate the starting point on the outside of the vehicleSelectionView box.
            fXY v2oSlope(Math::unitDirection(a, b));

            a.x += int(v2oSlope.x * float(VehicleSelectionView::getSizeX() / 2));
            a.y += int(v2oSlope.y * float(VehicleSelectionView::getSizeY() / 2));

            // Calculate the starting point on the outside of the objective box.
            iXY objectiveOutlineSize(3, 3);

            //fXY o2vSlope(Math::unitDirection(b, a));

            //b.x += o2vSlope.x * float(objectiveOutlineSize.x);
            //b.y += o2vSlope.y * float(objectiveOutlineSize.y);

            //screen.drawLine(a, b, Color::white);

            iRect r(objectivePos - objectiveOutlineSize, objectivePos + objectiveOutlineSize);
            //bltBlendRect(screen, r);
            screen->fillRect(r, Color::white);

            //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2;

            //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black);

            iXY oos(objectiveOutlineSize);
            iXY cornerPos;

            if (v2oSlope.x > 0 && v2oSlope.y > 0) {
                cornerPos = iXY(max.x, max.y);
                r = iRect(cornerPos - oos, cornerPos + oos);
            }
            if (v2oSlope.x > 0 && v2oSlope.y <= 0) {
                cornerPos = iXY(max.x, min.y);
                r = iRect(cornerPos - oos, cornerPos + oos);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y > 0) {
                cornerPos = iXY(min.x, max.y);
                r = iRect(cornerPos - oos, cornerPos + oos);
            }
            if (v2oSlope.x <= 0 && v2oSlope.y <= 0) {
                cornerPos = iXY(min.x, min.y);
                r = iRect(cornerPos - oos, cornerPos + oos);
            }

            screen->drawLine(cornerPos, b, Color::white);
            screen->fillRect(r, Color::white);

            //screen.bltLookup(r, Palette::darkGray256.getColorArray());
            //screen.drawButtonBorder(r, Color::white, Color::gray96);

            // Draw the name of the outpost.
        }}

    bltViewBackground(viewArea);

    OutpostStatus outpost_status;

    outpost_status = ObjectiveInterface::getOutpostStatus( CURRENT_SELECTED_OUTPOST_ID );

    if (vsvUnitGenOn) {
        sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit));
        clientArea.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);

        sprintf(strBuf, "%01d:%02d/%01d:%02d",
                    ((int)outpost_status.unit_generation_time_remaining) / 60,
                    ((int)outpost_status.unit_generation_time_remaining) % 60,
                    ((int)outpost_status.unit_generation_time) / 60,
                    ((int)outpost_status.unit_generation_time) % 60);
         
        clientArea.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    } else {
        sprintf(strBuf, "power off");
        clientArea.bltString(   productionUnitPos.x, productionUnitPos.y, 
                                strBuf, color);

        sprintf(strBuf, "power off");
        clientArea.bltString(   timeRequiredPos.x, timeRequiredPos.y, 
                                strBuf, color);
    }

    int unitPerPlayer = gameconfig->maxunits / gameconfig->maxplayers;
    sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer);
    clientArea.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color);

    drawUnitProfileInfo(clientArea, iXY(0, unitProfileDataY), highlightedUnitType);

    //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 );
    //clientArea.bltString(timeRemainingPos, strBuf, color);

    View::doDraw(viewArea, clientArea);

} // end VehicleSelectionView::doDraw
示例#6
0
void terrama2::services::analysis::core::Context::addDCPDataSeries(const AnalysisHashCode analysisHashCode,
                                                                   terrama2::core::DataSeriesPtr dataSeries,
                                                                   const std::string& dateFilter, const bool lastValue)
{
  std::lock_guard<std::recursive_mutex> lock(mutex_);

  bool needToAdd = false;
  for(auto dataset : dataSeries->datasetList)
  {
    if(!exists(analysisHashCode, dataset->id, dateFilter))
    {
      needToAdd = true;
      break;
    }
  }

  auto analysis = Context::getInstance().getAnalysis(analysisHashCode);

  if(!needToAdd)
    return;

  time_t ts = 0;
  struct tm t;
  char buf[16];
  ::localtime_r(&ts, &t);
  ::strftime(buf, sizeof(buf), "%Z", &t);


  boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone(buf));
  boost::local_time::local_date_time ldt = boost::local_time::local_microsec_clock::local_time(zone);

  auto dataManagerPtr = dataManager_.lock();
  if(!dataManagerPtr)
  {
    QString errMsg(QObject::tr("Invalid data manager."));
    throw terrama2::core::InvalidDataManagerException() << terrama2::ErrorDescription(errMsg);
  }

  auto dataProvider = dataManagerPtr->findDataProvider(dataSeries->dataProviderId);
  terrama2::core::Filter filter;
  filter.lastValue = lastValue;
  filter.discardAfter = analysisStartTime_[analysisHashCode];

  if(!dateFilter.empty())
  {
    double seconds = terrama2::core::TimeUtils::convertTimeString(dateFilter, "SECOND", "h");

    ldt -= boost::posix_time::seconds(seconds);

    std::unique_ptr<te::dt::TimeInstantTZ> titz(new te::dt::TimeInstantTZ(ldt));
    filter.discardBefore = std::move(titz);
  }

  //accessing data
  terrama2::core::DataAccessorPtr accessor = terrama2::core::DataAccessorFactory::getInstance().make(dataProvider, dataSeries, filter);
  std::unordered_map<terrama2::core::DataSetPtr, terrama2::core::DataSetSeries > seriesMap = accessor->getSeries(filter);

  if(seriesMap.empty())
  {
    QString errMsg(QObject::tr("The data series %1 does not contain data").arg(dataSeries->id));
    throw EmptyDataSeriesException() << terrama2::ErrorDescription(errMsg);
  }

  for(auto mapItem : seriesMap)
  {
    auto series = mapItem.second;

    std::shared_ptr<ContextDataSeries> dataSeriesContext(new ContextDataSeries);
    dataSeriesContext->series = series;

    terrama2::core::DataSetDcpPtr dcpDataset = std::dynamic_pointer_cast<const terrama2::core::DataSetDcp>(series.dataSet);
    if(!dcpDataset->position)
    {
      QString errMsg(QObject::tr("Invalid location for DCP."));
      throw InvalidDataSetException() << terrama2::ErrorDescription(errMsg);
    }

    int srid  = dcpDataset->position->getSRID();
    if(srid == 0)
    {
      if(dcpDataset->format.find("srid") != dcpDataset->format.end())
      {
        srid = std::stoi(dcpDataset->format.at("srid"));
        dcpDataset->position->setSRID(srid);
      }
    }

    // if data projection is in decimal degrees we need to convert it to a meter projection.
    auto spatialReferenceSystem = te::srs::SpatialReferenceSystemManager::getInstance().getSpatialReferenceSystem(dcpDataset->position->getSRID());
    std::string unitName = spatialReferenceSystem->getUnitName();
    if(unitName == "degree")
    {
      // Converts the data to UTM
      int sridUTM = terrama2::core::getUTMSrid(dcpDataset->position.get());
      dcpDataset->position->transform(sridUTM);
    }

    dataSeriesContext->rtree.insert(*dcpDataset->position->getMBR(), dcpDataset->id);


    ContextKey key;
    key.datasetId_ = series.dataSet->id;
    key.analysisHashCode_ = analysisHashCode;
    key.dateFilter_ = dateFilter;
    datasetMap_[key] = dataSeriesContext;
  }
}