Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
RawLayer.h
1 //
2 // A raw data layer, suitable for storing and displaying the type of
3 // generic spatial data contained in a Shapefile.
4 //
5 // Copyright (c) 2001-2011 Virtual Terrain Project
6 // Free for all uses, see license.txt for details.
7 //
8 
9 #ifndef RAWLAYERH
10 #define RAWLAYERH
11 
12 #include "vtdata/Features.h"
13 #include "Layer.h"
14 
15 class vtRawLayer : public vtLayer
16 {
17 public:
18  vtRawLayer();
19  virtual ~vtRawLayer();
20 
21  void SetGeomType(OGRwkbGeometryType type);
22  OGRwkbGeometryType GetGeomType();
23  vtFeatureSet *GetFeatureSet() { return m_pSet; }
24  void SetFeatureSet(vtFeatureSet *pSet) { m_pSet = pSet; }
25 
26  // implementation of vtLayer methods
27  bool GetExtent(DRECT &rect);
28  void DrawLayer(wxDC *pDC, vtScaledView *pView);
29  bool TransformCoords(vtProjection &proj);
30  bool OnSave(bool progress_callback(int) = NULL);
31  bool OnLoad();
32  bool AppendDataFrom(vtLayer *pL);
33  void GetProjection(vtProjection &proj);
34  void SetProjection(const vtProjection &proj);
35  void Offset(const DPoint2 &p);
36  void GetPropertyText(wxString &strIn);
37  void OnLeftDown(BuilderView *pView, UIContext &ui);
38 
39  void AddPoint(const DPoint2 &p2);
40  bool CreateFromOGRLayer(OGRLayer *pOGRLayer);
41  bool ReadFeaturesFromWFS(const char *szServerURL, const char *layername);
42  bool LoadWithOGR(const char *filename, bool progress_callback(int) = NULL);
43 
44  void ScaleHorizontally(double factor);
45  void ScaleVertically(double factor);
46  void OffsetVertically(double amount);
47 
48  void SetDrawStyle(const DrawStyle &style) { m_DrawStyle = style; }
49  DrawStyle GetDrawStyle() { return m_DrawStyle; }
50 
51  vtProjection *GetAtProjection()
52  {
53  if (m_pSet)
54  return &(m_pSet->GetAtProjection());
55  else
56  return NULL;
57  }
58  wxString GetLayerFilename()
59  {
60  if (m_pSet)
61  return wxString(m_pSet->GetFilename(), wxConvUTF8);
62  else
63  return vtLayer::GetLayerFilename();
64  }
65  void SetLayerFilename(const wxString &fname)
66  {
67  if (m_pSet)
68  m_pSet->SetFilename((const char *) fname.mb_str(wxConvUTF8));
69  vtLayer::SetLayerFilename(fname);
70  }
71 
72  void ReadGeoURL();
73  bool ImportFromXML(const char *fname);
74 
75  // speed optimization
76  void CreateIndex(int iSize);
77  void FreeIndex();
78 
79 protected:
80  vtFeatureSet *m_pSet;
81  DrawStyle m_DrawStyle;
82  bool m_bExtentComputed;
83  DRECT m_Extents;
84 };
85 
86 #endif // RAWLAYERH
87