LCOV - code coverage report
Current view: top level - src/libtraci - POI.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 76 76
Test Date: 2024-10-24 15:46:30 Functions: 87.1 % 31 27

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2017-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    POI.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Mario Krumnow
      17              : /// @author  Jakob Erdmann
      18              : /// @author  Michael Behrisch
      19              : /// @author  Robert Hilbrich
      20              : /// @date    30.05.2012
      21              : ///
      22              : // C++ TraCI client API implementation
      23              : /****************************************************************************/
      24              : #include <config.h>
      25              : 
      26              : #define LIBTRACI 1
      27              : #include "Domain.h"
      28              : #include <libsumo/POI.h>
      29              : #include <libsumo/StorageHelper.h>
      30              : 
      31              : 
      32              : namespace libtraci {
      33              : 
      34              : typedef Domain<libsumo::CMD_GET_POI_VARIABLE, libsumo::CMD_SET_POI_VARIABLE> Dom;
      35              : 
      36              : // ===========================================================================
      37              : // static member definitions
      38              : // ===========================================================================
      39              : std::vector<std::string>
      40           36 : POI::getIDList() {
      41           71 :     return Dom::getStringVector(libsumo::TRACI_ID_LIST, "");
      42              : }
      43              : 
      44              : 
      45              : int
      46           10 : POI::getIDCount() {
      47           20 :     return Dom::getInt(libsumo::ID_COUNT, "");
      48              : }
      49              : 
      50              : 
      51              : std::string
      52            4 : POI::getType(const std::string& poiID) {
      53            4 :     return Dom::getString(libsumo::VAR_TYPE, poiID);
      54              : }
      55              : 
      56              : 
      57              : libsumo::TraCIColor
      58            4 : POI::getColor(const std::string& poiID) {
      59            4 :     return Dom::getCol(libsumo::VAR_COLOR, poiID);
      60              : }
      61              : 
      62              : 
      63              : libsumo::TraCIPosition
      64         2007 : POI::getPosition(const std::string& poiID, const bool includeZ) {
      65         2007 :     return includeZ ? Dom::getPos3D(libsumo::VAR_POSITION3D, poiID) : Dom::getPos(libsumo::VAR_POSITION, poiID);
      66              : }
      67              : 
      68              : 
      69              : double
      70            4 : POI::getWidth(const std::string& poiID) {
      71            4 :     return Dom::getDouble(libsumo::VAR_WIDTH, poiID);
      72              : }
      73              : 
      74              : 
      75              : double
      76            4 : POI::getHeight(const std::string& poiID) {
      77            4 :     return Dom::getDouble(libsumo::VAR_HEIGHT, poiID);
      78              : }
      79              : 
      80              : 
      81              : double
      82            4 : POI::getAngle(const std::string& poiID) {
      83            4 :     return Dom::getDouble(libsumo::VAR_ANGLE, poiID);
      84              : }
      85              : 
      86              : 
      87              : std::string
      88            1 : POI::getImageFile(const std::string& poiID) {
      89            1 :     return Dom::getString(libsumo::VAR_IMAGEFILE, poiID);
      90              : }
      91              : 
      92              : 
      93            6 : LIBTRACI_PARAMETER_IMPLEMENTATION(POI, POI)
      94              : 
      95              : 
      96              : void
      97            1 : POI::setType(const std::string& poiID, const std::string& poiType) {
      98            1 :     Dom::setString(libsumo::VAR_TYPE, poiID, poiType);
      99            1 : }
     100              : 
     101              : 
     102              : void
     103            1 : POI::setPosition(const std::string& poiID, double x, double y) {
     104            1 :     tcpip::Storage content;
     105            1 :     content.writeUnsignedByte(libsumo::POSITION_2D);
     106            1 :     content.writeDouble(x);
     107            1 :     content.writeDouble(y);
     108            1 :     Dom::set(libsumo::VAR_POSITION, poiID, &content);
     109            1 : }
     110              : 
     111              : 
     112              : void
     113            1 : POI::setColor(const std::string& poiID, const libsumo::TraCIColor& c) {
     114            1 :     Dom::setCol(libsumo::VAR_COLOR, poiID, c);
     115            1 : }
     116              : 
     117              : 
     118              : void
     119            1 : POI::setWidth(const std::string& poiID, double width) {
     120            1 :     Dom::setDouble(libsumo::VAR_WIDTH, poiID, width);
     121            1 : }
     122              : 
     123              : 
     124              : void
     125            1 : POI::setHeight(const std::string& poiID, double height) {
     126            1 :     Dom::setDouble(libsumo::VAR_HEIGHT, poiID, height);
     127            1 : }
     128              : 
     129              : 
     130              : void
     131            1 : POI::setAngle(const std::string& poiID, double angle) {
     132            1 :     Dom::setDouble(libsumo::VAR_ANGLE, poiID, angle);
     133            1 : }
     134              : 
     135              : 
     136              : void
     137            1 : POI::setImageFile(const std::string& poiID, const std::string& imageFile) {
     138            1 :     Dom::setString(libsumo::VAR_IMAGEFILE, poiID, imageFile);
     139            1 : }
     140              : 
     141              : 
     142              : bool
     143           23 : POI::add(const std::string& poiID, double x, double y, const libsumo::TraCIColor& color, const std::string& poiType,
     144              :          int layer, const std::string& imgFile, double width, double height, double angle, const std::string& icon) {
     145           23 :     tcpip::Storage content;
     146              :     StoHelp::writeCompound(content, 9);
     147              :     StoHelp::writeTypedString(content, poiType);
     148           23 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
     149           23 :     content.writeUnsignedByte(color.r);
     150           23 :     content.writeUnsignedByte(color.g);
     151           23 :     content.writeUnsignedByte(color.b);
     152           23 :     content.writeUnsignedByte(color.a);
     153              :     StoHelp::writeTypedInt(content, layer);
     154           23 :     content.writeUnsignedByte(libsumo::POSITION_2D);
     155           23 :     content.writeDouble(x);
     156           23 :     content.writeDouble(y);
     157              :     StoHelp::writeTypedString(content, imgFile);
     158              :     StoHelp::writeTypedDouble(content, width);
     159              :     StoHelp::writeTypedDouble(content, height);
     160              :     StoHelp::writeTypedDouble(content, angle);
     161              :     StoHelp::writeTypedString(content, icon);
     162           23 :     Dom::set(libsumo::ADD, poiID, &content);
     163           23 :     return true;
     164           23 : }
     165              : 
     166              : 
     167              : bool
     168            2 : POI::remove(const std::string& poiID, int layer) {
     169            2 :     Dom::setInt(libsumo::REMOVE, poiID, layer);
     170            2 :     return true;
     171              : }
     172              : 
     173              : 
     174              : void
     175            7 : POI::highlight(const std::string& poiID, const libsumo::TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
     176            7 :     tcpip::Storage content;
     177            7 :     StoHelp::writeCompound(content, alphaMax > 0 ? 5 : 2);
     178            7 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
     179            7 :     content.writeUnsignedByte(col.r);
     180            7 :     content.writeUnsignedByte(col.g);
     181            7 :     content.writeUnsignedByte(col.b);
     182            7 :     content.writeUnsignedByte(col.a);
     183              :     StoHelp::writeTypedDouble(content, size);
     184            7 :     if (alphaMax > 0) {
     185            7 :         content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     186            7 :         content.writeUnsignedByte(alphaMax);
     187              :         StoHelp::writeTypedDouble(content, duration);
     188            7 :         content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     189            7 :         content.writeUnsignedByte(type);
     190              :     }
     191            7 :     Dom::set(libsumo::VAR_HIGHLIGHT, poiID, &content);
     192            7 : }
     193              : 
     194              : 
     195         8164 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(POI, POI)
     196              : 
     197              : 
     198              : }
     199              : 
     200              : 
     201              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1