50 "ossimGdalOgrVectorAnnotation",
55 static ossimTrace traceDebug(
"ossimGdalOgrVectorAnnotation:debug");
57 static const char SHAPEFILE_COLORS_AUTO_KW[] =
58 "shapefile_colors_auto";
60 static const char NORMALIZED_RGB_BRUSH_COLOR_KW[] =
61 "shapefile_normalized_rgb_brush_color";
63 static const char NORMALIZED_RGB_PEN_COLOR_KW[] =
64 "shapefile_normalized_rgb_pen_color";
66 static const char POINT_SIZE_KW[] =
67 "shapefile_point_size";
70 bool doubleLess(
double first,
double second,
double epsilon,
bool orequal =
false)
72 if (fabs(first - second) < epsilon)
76 return (first < second);
79 bool doubleGreater(
double first,
double second,
double epsilon,
bool orequal =
false)
81 if (fabs(first - second) < epsilon)
85 return (first > second);
111 static const ossimRgbColor autoColorArray[AUTO_COLOR_ARRAY_COUNT] =
141 double maxX,
double maxY)
const 161 double maxX,
double maxY)
const 204 theLayersToRenderFlagList(),
206 thePenColor(255,255,255),
207 theBrushColor(255,255,255),
210 thePointWidthHeight(1, 1),
214 theIsExternalGeomFlag(false),
216 m_needPenColor(false),
217 m_geometryDistance(0.0),
267 const char* MODULE =
"ossimGdalOgrVectorAnnotation::open";
278 if(file ==
"")
return false;
318 vector<ossimGpt> points;
336 bool successfulTest =
true;
340 for(i = 0; (i < layerCount)&&successfulTest; ++i)
342 OGRLayer* layer = NULL;
358 OGRSpatialReference* spatialReference = layer->GetSpatialRef();
362 if(!spatialReference)
374 <<
" No spatial reference given, assuming geographic" 378 else if(spatialReference->IsLocal())
384 <<
" Only geographic vectors and projected vectors " 385 <<
"are supported, layer " << i <<
" is local" << endl;
387 successfulTest =
false;
399 <<
" layer " << i <<
" is null." << endl;
401 successfulTest =
false;
404 if(successfulTest&&layer)
429 if (layer->GetSpatialRef())
431 double unitValue = layer->GetSpatialRef()->GetLinearUnits();
459 points.push_back(g1);
460 points.push_back(g2);
461 points.push_back(g3);
462 points.push_back(g4);
468 layer->GetExtent(&extent,
true);
485 extent.MinX = rect2.
ul().
x;
486 extent.MinY = rect2.
ul().
y;
487 extent.MaxX = rect2.
lr().
x;
488 extent.MaxY = rect2.
lr().
y;
492 if (points.size() == 4)
496 points[0].lon = g1.
lon;
500 points[0].lat = g1.
lat;
504 points[1].lon = g2.
lon;
508 points[1].lat = g2.
lat;
512 points[2].lon = g3.
lon;
516 points[2].lat = g3.
lat;
520 points[3].lon = g4.
lon;
524 points[3].lat = g4.
lat;
584 << MODULE <<
" DEBUG:" 585 <<
"\ntheViewProjection:" 602 if (points.size() == 0)
612 std::vector<ossimDpt> rectTmp;
613 rectTmp.resize(points.size());
614 for(std::vector<ossimGpt>::size_type index=0; index < points.size(); ++index)
619 if (rectTmp.size() > 3)
704 ossimGpt origin(centerLat, centerLon, 0.0);
770 list<long> featuresToRender;
775 list<long>::iterator current = featuresToRender.begin();
780 vector<ossimAnnotationObject*> objectList;
782 while(current!=featuresToRender.end())
790 objectList[i]->draw(*image.
get());
801 polyObject->
draw(*image.
get());
855 if(!property.
valid())
return;
975 const char* prefix)
const 1015 border +=
" degrees";
1047 newPrefix +=
"view_proj.";
1079 if (penColorStr.
split(
",").size() == 3)
1081 r = penColorStr.
split(
",")[0].toInt();
1082 g = penColorStr.
split(
",")[1].toInt();
1083 b = penColorStr.
split(
",")[2].toInt();
1084 if (r == 0 && g == 0 && b == 0)
1101 if (brushColorStr.
split(
",").size() == 3)
1103 r = brushColorStr.
split(
",")[0].toInt();
1104 g = brushColorStr.
split(
",")[1].toInt();
1105 b = brushColorStr.
split(
",")[2].toInt();
1106 if (r == 0 && g == 0 && b == 0)
1138 unitPrefix.
c_str());
1180 out <<
"ossimGdalOgrVectorAnnotation::print" 1181 <<
"\ntheLayersToRenderFlagList.size(): " 1188 out <<
"layer[" << i <<
"]:" 1203 std::multimap<long, ossimAnnotationObject*>::iterator iter =
1281 for(
int i = 0; i < upper; ++i)
1286 OGRLayer* layer = NULL;
1312 layer->ResetReading();
1313 layer->GetExtent(&extent,
true);
1314 layer->ResetReading();
1316 OGRFeature* feature = NULL;
1343 while( (feature = layer->GetNextFeature()) != NULL)
1347 OGRGeometry* geom = feature->GetGeometryRef();
1351 switch(geom->getGeometryType())
1354 case wkbMultiPoint25D:
1361 (OGRMultiPoint*)geom,
1374 OGRPolygon* poly = (OGRPolygon*)geom;
1375 OGRLinearRing* ring = poly->getExteriorRing();
1376 int numPoints = ring->getNumPoints();
1379 (OGRPolygon*)bufferGeom,
1391 case wkbLineString25D:
1399 (OGRLineString*)geom,
1415 case wkbMultiPolygon25D:
1416 case wkbMultiPolygon:
1426 (OGRMultiPolygon*)bufferGeom,
1432 (OGRMultiPolygon*)geom,
1438 case wkbMultiLineString:
1445 (OGRMultiLineString*)geom,
1454 <<
"ossimGdalOgrVectorAnnotation::initializeTables WARNING\n" 1456 << OGRGeometryTypeToName(geom->getGeometryType())
1463 geom->getEnvelope(&extent);
1515 <<
"ossimGdalOgrVectorAnnotation::initializeTables(): leaving..." 1535 ((*current).second)->
unref();
1550 featureList.push_back((*iter).second);
1569 if(reference->IsGeographic()||reference->IsLocal())
1577 char* wktString = NULL;
1579 reference->exportToWkt(&wktString);
1597 OGRLinearRing* ring = poly->getExteriorRing();
1619 int upper = ring->getNumPoints();
1620 vector<ossimGpt> points(upper);
1621 for(
int i = 0; i < upper; ++i)
1624 ring->getPoint(i, &ogrPt);
1654 int bound = poly->getNumInteriorRings();
1657 for(
int i = 0; i < bound; ++i)
1659 ring = poly->getInteriorRing(i);
1663 int upper = ring->getNumPoints();
1664 vector<ossimGpt> points(upper);
1665 for(j = 0; j < upper; ++j)
1668 ring->getPoint(j, &ogrPt);
1671 ossimDpt eastingNorthing(ogrPt.getX(),
1674 points[j] = mapProj->
inverse(eastingNorthing);
1710 int upper = lineString->getNumPoints();
1727 vector<ossimGpt> polyLine(upper);
1728 for(
int i = 0; i < upper; ++i)
1732 lineString->getPoint(i, &ogrPt);
1736 ossimDpt eastingNorthing(ogrPt.getX(),
1739 polyLine[i] = mapProj->
inverse(eastingNorthing);
1743 polyLine[i] =
ossimGpt(ogrPt.getY(),
1779 ossim_uint32 numGeometries = multiLineString->getNumGeometries();
1786 vector<ossimGeoPolygon> geoPoly;
1787 for(
ossim_uint32 geomIdx = 0; geomIdx < numGeometries; ++geomIdx)
1789 OGRGeometry* geomRef = multiLineString->getGeometryRef(geomIdx);
1790 OGRLineString* lineString = (OGRLineString*)geomRef;
1793 int upper = lineString->getNumPoints();
1794 vector<ossimGpt> polyLine(upper);
1795 for(
int i = 0; i < upper; ++i)
1799 lineString->getPoint(i, &ogrPt);
1803 ossimDpt eastingNorthing(ogrPt.getX(),
1806 polyLine[i] = mapProj->
inverse(eastingNorthing);
1810 polyLine[i] =
ossimGpt(ogrPt.getY(),
1855 ossimDpt eastingNorthing(point->getX(),
1858 gpt = mapProj->
inverse(eastingNorthing);
1885 OGRMultiPoint* multiPoint,
1888 ossim_uint32 numGeometries = multiPoint->getNumGeometries();
1914 OGRGeometry* geomRef = multiPoint->getGeometryRef(i);
1916 ( (geomRef->getGeometryType()==wkbPoint) ||
1917 (geomRef->getGeometryType()==wkbPoint25D) ) )
1919 OGRPoint* point = (OGRPoint*)geomRef;
1923 ossimDpt eastingNorthing(point->getX(),
1945 OGRMultiPolygon* multiPolygon,
1959 ossim_uint32 numGeometries = multiPolygon->getNumGeometries();
1966 vector<ossimGeoPolygon> geoPoly;
1967 for(
ossim_uint32 geomIdx = 0; geomIdx < numGeometries; ++geomIdx)
1969 OGRGeometry* geomRef = multiPolygon->getGeometryRef(geomIdx);
1971 ( (geomRef->getGeometryType()==wkbPolygon) ||
1972 (geomRef->getGeometryType()==wkbPolygon25D) ) )
1975 OGRPolygon* poly = (OGRPolygon*)geomRef;
1976 OGRLinearRing* ring = poly->getExteriorRing();
1984 ringPointIdx < upper;
1988 ring->getPoint(ringPointIdx, &ogrPt);
1991 geoPoly[currentPoly].addPoint(
1996 geoPoly[currentPoly].addPoint(ogrPt.getY(),
2009 interiorRingIdx < bound;
2012 ring = poly->getInteriorRing(interiorRingIdx);
2017 currentPoly = geoPoly.size()-1;
2022 interiorRingPointIdx < upper;
2023 ++interiorRingPointIdx)
2026 ring->getPoint(interiorRingPointIdx, &ogrPt);
2029 geoPoly[currentPoly].addPoint(
2035 geoPoly[currentPoly].addPoint(ogrPt.getY(),
2122 if ( (thickness > 0) && (thickness < 256) )
2129 <<
"ossimGdalOgrVectorAnnotation::setThickness range error: " 2131 <<
"\nValid range: 1 to 255" 2172 <<
"ossimGdalOgrVectorAnnotation::loadExternalGeometryFile" 2174 <<
"\nExternal projection loaded from geometry file." 2175 <<
"\nProjection dump:" << std::endl;
2197 if ( fgdcXmlDoc->
open(xmlFile) )
2229 const char* lookup = 0;
2240 getEntryNumber(kwl, unitPrefix.
c_str());
2268 lookup = kwl.
find(NORMALIZED_RGB_BRUSH_COLOR_KW);
2278 if ( (r >= 0.0) && (r <=1.0) )
2282 if ( (g >= 0.0) && (g <=1.0) )
2286 if ( (b >= 0.0) && (b <=1.0) )
2313 lookup = kwl.
find(NORMALIZED_RGB_PEN_COLOR_KW);
2323 if ( (r >= 0.0) && (r <=1.0) )
2327 if ( (g >= 0.0) && (g <=1.0) )
2331 if ( (b >= 0.0) && (b <=1.0) )
2342 lookup = kwl.
find(POINT_SIZE_KW);
2352 if ( (
x > 0.0) && (
y > 0.0) )
2379 bool autocolors =
false;
2381 findPreference(SHAPEFILE_COLORS_AUTO_KW);
2390 if (currentAutoColorArrayIndex >= AUTO_COLOR_ARRAY_COUNT)
2392 currentAutoColorArrayIndex = 0;
2403 ++currentAutoColorArrayIndex;
2404 if (currentAutoColorArrayIndex >= AUTO_COLOR_ARRAY_COUNT)
2406 currentAutoColorArrayIndex = 0;
2414 findPreference(NORMALIZED_RGB_PEN_COLOR_KW);
2424 if ( (r >= 0.0) && (r <=1.0) )
2428 if ( (g >= 0.0) && (g <=1.0) )
2432 if ( (b >= 0.0) && (b <=1.0) )
2440 findPreference(NORMALIZED_RGB_BRUSH_COLOR_KW);
2450 if ( (r >= 0.0) && (r <=1.0) )
2454 if ( (g >= 0.0) && (g <=1.0) )
2458 if ( (b >= 0.0) && (b <=1.0) )
2468 findPreference(POINT_SIZE_KW);
2477 if ( (
x > 0.0) && (
y > 0.0) )
void computeDefaultView()
void setQuery(const ossimString &query)
virtual const ossimDpt & getDecimalDegreesPerPixel() const
Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing...
void loadOmdFile()
Looks for "file.omd" and loads pen, brush and point settings if present.
std::multimap< long, ossimAnnotationObject * > theFeatureCacheTable
void loadExternalGeometryFile()
Will set theViewProjection if geometry file is present with projection.
bool doubleGreater(double first, double second, double epsilon, bool orequal=false)
virtual void setPenColor(const ossimRgbVector &penColor)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void loadExternalImageGeometryFromXml()
Will set theViewProjection if xml file is present with projection.
static const char * BRUSH_COLOR_KW
ossimFilename noExtension() const
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimGdalOgrVectorAnnotation(ossimImageSource *inputSource=0)
unsigned char getR() const
virtual void setWidthHeight(const ossimDpt &pt)
Sets the width and height of point.
virtual void setFillFlag(bool flag)
ossimRefPtr< ossimImageGeometry > theImageGeometry
std::vector< ossimOgrGdalFeatureNode > theFeatureList
double lond() const
Will convert the radian measure to degrees.
virtual void draw(ossimRgbImage &anImage) const
ossimRgbColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
Constructor that takes an rgb.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
Represents serializable keyword/value map.
bool addFile(const char *file)
virtual void transform(ossimImageGeometry *projection)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Attempts to initialize a transform and a projection given the KWL.
const char * find(const char *key) const
void loadPolygon(long id, OGRPolygon *polygon, ossimMapProjection *mapProj)
void loadPoint(long id, OGRPoint *point, ossimMapProjection *mapProj)
std::ostream & print(std::ostream &out) const
Prints contents to output stream.
ossimUnitType m_geometryDistanceType
void setR(unsigned char R)
const ossimDpt & ul() const
ossim_float64 m_geometryDistance
virtual void transform(ossimImageGeometry *projection)
void loadLineString(long id, OGRLineString *lineString, ossimMapProjection *mapProj)
bool doubleLess(double first, double second, double epsilon, bool orequal=false)
static ossimString toString(bool aValue)
Numeric to string methods.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimOgrGdalLayerNode(const ossimDrect &bounds)
virtual bool isGeographic() const
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
virtual void transform(ossimImageGeometry *projection)=0
const ossimIpt & ul() const
ossimRgbColor()
Default constructor (green)
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
RTTI_DEF2(ossimGdalOgrVectorAnnotation, "ossimGdalOgrVectorAnnotation", ossimAnnotationSource, ossimViewInterface)
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
void loadMultiPoint(long id, OGRMultiPoint *multiPoint, ossimMapProjection *mapProj)
ossimDrect theBoundingRect
ossimDrect combine(const ossimDrect &rect) const
double latd() const
Will convert the radian measure to degrees.
const ossimIpt & ll() const
virtual void setNumberOfBands(ossim_uint32 bands)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual ossim_int32 getThickness() const
virtual ossimGpt inverse(const ossimDpt &projectedPoint) const =0
Will take a point in meters and convert it to ground.
virtual void setBrushColor(const ossimRgbVector &brushColor)
virtual void drawAnnotations(ossimRefPtr< ossimImageData > tile)
bool intersects(const ossimDrect &rect) const
virtual void getBoundingRect(ossimDrect &rect) const =0
virtual void setUlGpt(const ossimGpt &ulGpt)
virtual void setMetersPerPixel(const ossimDpt &gsd)
const ossimDatum * datum() const
datum().
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
void setB(unsigned char B)
ossim_int32 toInt32() const
virtual void setFillFlag(bool flag)
virtual void setPolyType(ossimPolyType polyType)
OGREnvelope theBoundingExtent
virtual void computeBoundingRect()
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
OGRDataSource * theDataSource
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
void loadMultiLineString(long id, OGRMultiLineString *multiLineString, ossimMapProjection *mapProj)
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
bool completely_within(const ossimDrect &rect) const
virtual void setNumericType(ossimNumericPropertyType type)
ossimOgrGdalFeatureNode(long id, const ossimDrect &rect)
virtual bool setView(ossimObject *baseObject)
virtual ossimDataObjectStatus validate() const
bool localToWorld(const ossimDpt &local_pt, ossimGpt &world_pt) const
Exposes the 3D projection from image to world coordinates.
virtual ossimFilename getFilename() const
static const char * QUERY_KW
bool toBool() const
String to numeric methods.
void loadMultiPolygon(long id, OGRMultiPolygon *multiPolygon, ossimMapProjection *mapProj)
void getFeature(vector< ossimAnnotationObject *> &featureList, long id)
container class for rgb value.
unsigned int ossim_uint32
static const char * FILL_FLAG_KW
void getDefaults()
Will set thePenColor and theBrushColor if keyword found in preferences.
Class for FGDC XML doc parsing.
static const char * BORDER_SIZE_KW
virtual ossimIrect getImageRectangle() const
unsigned char getB() const
const ossimIpt & lr() const
virtual void setOrigin(const ossimGpt &origin)
void setGeometryBuffer(ossim_float64 distance, ossimUnitType type)
static ossimString downcase(const ossimString &aString)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
virtual ~ossimGdalOgrVectorAnnotation()
void updateAnnotationSettings()
vector< bool > theLayersToRenderFlagList
bool intersects(const ossimDrect &rect) const
virtual void transform(ossimImageGeometry *projection)
virtual const ossimGpt & getUlGpt() const
virtual ossimRgbVector getBrushColor() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual void addPoint(const ossimGpt &point)
static ossimPreferences * instance()
const ossimIpt & ur() const
void setG(unsigned char G)
bool theIsExternalGeomFlag
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
void unref() const
decrement the reference count by one, indicating that a pointer to this object is referencing it...
bool intersects(double minX, double minY, double maxX, double maxY) const
static ossimProjectionFactoryRegistry * instance()
static const char * UNITS_KW
ossimRefPtr< ossimProjection > getProjection()
Gets projection from document.
std::vector< ossimOgrGdalLayerNode * > theLayerTable
unsigned char getG() const
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void transform(ossimImageGeometry *projection)
ossimRgbVector thePenColor
bool intersects(double minX, double minY, double maxX, double maxY) const
virtual void setThickness(ossim_uint8 thickness)
virtual ossimGpt origin() const =0
virtual double getPointRadius() const
void verifyViewParams()
Checks for nan scale and tie point.
void getFeatures(std::list< long > &result, const ossimIrect &rect)
void getIdList(std::list< long > &idList, const ossimDrect &aoi) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
const ossimDpt & ur() const
virtual bool isOpen() const
ossimUnitType theBorderSizeUnits
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
bool intersects(const ossimDrect &rect) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual ossimObject * dup() const
void transformObjectsFromView()
Uses theViewProjection.
std::multimap< long, ossimAnnotationObject * > getFeatureTable()
ossimDrect theBoundingRect
virtual void transform(ossimImageGeometry *projection)
ossimRgbVector theBrushColor
static const char * PEN_COLOR_KW
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
bool open(const ossimFilename &xmlFileName)
Open method.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the transform (if any) and projection (if any) states to the KWL.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
const ossimDpt & ll() const
bool toOssimKwl(const ossimString &wktString, ossimKeywordlist &kwl, const char *prefix=NULL) const
virtual void setFillFlag(bool flag)
std::basic_istringstream< char > istringstream
Class for char input memory streams.
static const char * POINT_WIDTH_HEIGHT_KW
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void setCurrentImageData(ossimRefPtr< ossimImageData > &imageData)
Allows you to change the image data that this RgbImage object operates on.
virtual ossimObject * getView()
virtual ossimDpt getMetersPerPixel() const
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
virtual void setFillFlag(bool flag)
Sets the fill flag.
float distance(double lat1, double lon1, double lat2, double lon2, int units)
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
ossimProjection * createProjFromReference(OGRSpatialReference *reference) const
const ossimDpt & lr() const
std::vector< ossimString > m_layerNames
static const char * FILENAME_KW
static const char * THICKNESS_KW
virtual bool getFillFlag() const
virtual std::ostream & print(std::ostream &out) const
Prints data members to stream.
ossimDpt thePointWidthHeight
virtual void setPointRadius(double r)
void initializeBoundingRec(vector< ossimGpt > points)
ossimFilename theFilename
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool setCurrentEntry(ossim_uint32 entryIdx)
std::basic_ostream< char > ostream
Base class for char output streams.
void setCacheRefreshBit()
virtual ossimRgbVector getPenColor() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual void setThickness(ossim_int32 thickness)