Include GeometryEngine

993
6
07-21-2020 05:09 PM
johnmarker
New Contributor III

Hello,

I have a program that needs to use GeometryEngine. It is used in this line

        const Geometry pointGeom = GeometryEngine::normalizeCentralMeridian(clickedPoint);
When i try to
#include <GeometryEngine>

I get an error saying file not found. How to I get access to the the GeometryEngine class?

p.s. I have similar issues with SimpleMarkerSymbol.
0 Kudos
6 Replies
JamesBallard1
Esri Regular Contributor

Hi john marker‌,

   We provide some Qt project include files to set everything up. They are included in the ideintegration folder included with the setup. If you create one of our project templates, you can see how they look.

It usually looks like this:

ARCGIS_RUNTIME_VERSION = 100.8
include($$PWD/arcgisruntime.pri)‍‍‍‍‍‍

And then inside the arcgisruntime.pri file that comes with a template, it will include either 

sdk/ideintegration/esri_runtime_qt.pri (for Widgets)

sdk/ideintegration/arcgis_runtime_qml_cpp.pri (for Qt Quick)

You can alternately include either of those files directly in your Qt project.
Those will setup your compiler include paths as well as the linker paths.

Let us know if that gets things working for you.

johnmarker
New Contributor III

Oh Wait. When I #include these classes like GeometryEngine I'm wanting to include their .h files, so it would be

#include <GeometryEngine.h>
rather than 
#include <GeometryEngine>

So if in my program I'm wanting to access a member variable from one of these classes, lets say I want to use m_polylineBuilder, then when I include 
#include <PolylineBuilder.h> that will get me access to the m_polylineBuilder member variable?

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
JamesBallard1
Esri Regular Contributor

Yes, you got it. We provide .h extension header files, so they must be included with the extension.

Yes, you'd include PolylineBuilder.h to get access to that class and have a m_polylineBuilder member variable.

0 Kudos
johnmarker
New Contributor III

Thank you for your help! 

I just have one more question. Is there a link to see the .h file of these classes to see what member variables are already declared? For example, to see if m_polylineBuilder is declared and initialized in the .h file or do most of the classes not have member variables to use and I would have to declare and initialize the variable on my own?

Reason for this, I assumed m_polylineBuilder was a default member variable within the class. I tried to use it, however I got an error saying it was undeclared. Once I added 

PolylineBuilder* m_polylineBuilder = nullptr;

I also could not declare it with

Esri::ArcGISRuntime::PolylineBuilder* m_polylineBuilder = new Esri::ArcGISRuntime::PolylineBuilder(this);;

Then it worked. But I would have thought this would have been taken care of in the .h file and when i include <polylineBuilder.h> then I would have access to it?


					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
0 Kudos
JamesBallard1
Esri Regular Contributor

Hi john marker‌,

   It sounds like there is some confusion about some C++ concepts. The Runtime SDK headers provide the declaration of the classes, but as the consumer of these objects, it is your responsibility to make sure they are initialized properly.

>I assumed m_polylineBuilder was a default member variable within the class

Which class? I assume that is a class you are working with and not one of the classes/files that are included with the Runtime SDK.

Here's an example of creating a PolylineBuilder object.

Header file:

namespace Esri
{
namespace ArcGISRuntime
{
class Map;
class MapQuickView;
class PolylineBuilder; // <====== forward declaration
}
}

#include <QObject>

class Untitled107 : public QObject
{
  Q_OBJECT

  Q_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)

public:
  explicit Untitled107(QObject* parent = nullptr);
  ~Untitled107() override;

signals:
  void mapViewChanged();

private:
  Esri::ArcGISRuntime::MapQuickView* mapView() const;
  void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView);

  Esri::ArcGISRuntime::PolylineBuilder* m_polyBuilder = nullptr; // <====== declared as a member variable for this project
  Esri::ArcGISRuntime::Map* m_map = nullptr;
  Esri::ArcGISRuntime::MapQuickView* m_mapView = nullptr;
};

And then in the .cpp file, you can include the header and initialize the object

#include "Untitled107.h"

#include "Basemap.h"
#include "Map.h"
#include "MapQuickView.h"
#include "PolylineBuilder.h" // <=== include Runtime SDK header for this object

#include <QUrl>

using namespace Esri::ArcGISRuntime;

Untitled107::Untitled107(QObject* parent /* = nullptr */):
  QObject(parent),
  m_polyBuilder(new PolylineBuilder(SpatialReference::wgs84(), this)), // <=== initialize the object
  m_map(new Map(Basemap::topographic(this), this))
{
}

Untitled107::~Untitled107()
{
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This is an example of adding a PolylineBuilder to one of our template projects.

johnmarker
New Contributor III

Wow. Yeah... I was definitely a little confused, but it makes a lot more sense now! I appreciate your time and help with all of this!