1 #ifndef OSMSCOUT_UTIL_PROJECTION_H 2 #define OSMSCOUT_UTIL_PROJECTION_H 74 #ifdef OSMSCOUT_HAVE_SSE2 76 ALIGN16_BEG
double lon[2] ALIGN16_END;
77 ALIGN16_BEG
double lat[2] ALIGN16_END;
84 : projection(projection)
85 #ifdef OSMSCOUT_HAVE_SSE2
101 #ifdef OSMSCOUT_HAVE_SSE2 103 this->lon[count]=lon;
104 this->lat[count]=lat;
126 #ifdef OSMSCOUT_HAVE_SSE2 141 virtual bool CanBatch()
const = 0;
142 virtual bool IsValid()
const = 0;
147 virtual bool IsValidFor(
const GeoCoord& coord)
const = 0;
151 return GeoCoord(lat,lon);
202 return magnification;
218 return lon>=lonMin && lon<=lonMax && lat>=latMin && lat<=latMax;
225 double lonMax,
double latMax)
const 227 return !(lonMin>this->lonMax ||
228 lonMax<this->lonMin ||
229 latMin>this->latMax ||
230 latMax<this->latMin);
235 return GeoBox(GeoCoord(latMin,lonMin),
236 GeoCoord(latMax,lonMax));
244 boundingBox.Set(GeoCoord(latMin,lonMin),
245 GeoCoord(latMax,lonMax));
282 return width*dpi/25.4;
295 return pixel*25.4/dpi;
305 virtual bool PixelToGeo(
double x,
double y,
306 double& lon,
double& lat)
const = 0;
314 virtual bool GeoToPixel(
const GeoCoord& coord,
315 double& x,
double& y)
const = 0;
318 virtual void GeoToPixel(
const BatchTransformer& transformData)
const = 0;
370 return coord.GetLat() >= MinLat && coord.GetLat() <= MaxLat &&
371 coord.GetLon() >= MinLon && coord.GetLon() <= MaxLon;
374 bool Set(
const GeoCoord& coord,
375 const Magnification& magnification,
376 size_t width,
size_t height)
378 return Set(coord,0.0,magnification,GetDPI(),width,height);
381 bool Set(
const GeoCoord& coord,
383 const Magnification& magnification,
384 size_t width,
size_t height)
386 return Set(coord,angle,magnification,GetDPI(),width,height);
389 bool Set(
const GeoCoord& coord,
390 const Magnification& magnification,
392 size_t width,
size_t height)
394 return Set(coord,0.0,magnification,dpi,width,height);
419 bool Set(
const GeoCoord& coord,
421 const Magnification& magnification,
423 size_t width,
size_t height);
425 bool PixelToGeo(
double x,
double y,
426 double& lon,
double& lat)
const override;
429 GeoCoord &coord)
const 433 if (PixelToGeo(x,y,lon,lat)){
440 bool GeoToPixel(
const GeoCoord& coord,
441 double& x,
double& y)
const override;
443 bool Move(
double horizPixel,
448 return Move(0,pixel);
453 return Move(0,-pixel);
458 return Move(-pixel,0);
463 return Move(pixel,0);
468 return useLinearInterpolation;
477 this->useLinearInterpolation=useLinearInterpolation;
481 void GeoToPixel(
const BatchTransformer& transformData)
const override;
504 #ifdef OSMSCOUT_HAVE_SSE2 509 v2df sse2ScaleGradtorad;
514 virtual bool SetInternal(
double lonMin,
double latMin,
515 double lonMax,
double latMax,
516 const Magnification& magnification,
518 size_t width,
size_t height);
535 return coord.GetLat() >= -85.0511 && coord.GetLat() <= +85.0511 &&
536 coord.GetLon() >= -180.0 && coord.GetLon() <= +180.0;
539 bool Set(
const OSMTileId& tile,
540 const Magnification& magnification,
541 size_t width,
size_t height)
543 return Set(tile,magnification,GetDPI(),width,height);
546 bool Set(
const OSMTileId& tile,
547 const Magnification& magnification,
549 size_t width,
size_t height);
551 bool Set(
const OSMTileIdBox& tileBox,
552 const Magnification& magnification,
554 size_t width,
size_t height);
556 bool PixelToGeo(
double x,
double y,
557 double& lon,
double& lat)
const override;
559 bool GeoToPixel(
const GeoCoord& coord,
560 double& x,
double& y)
const override;
564 return useLinearInterpolation;
573 useLinearInterpolation = b;
578 void GeoToPixel(
const BatchTransformer& transformData)
const override;
bool useLinearInterpolation
switch to enable linear interpolation of latitude to pixel computation
Definition: Projection.h:502
double pixelSize
Size of a pixel in meter.
Definition: Projection.h:59
double ConvertWidthToPixel(double width) const
Definition: Projection.h:280
GeoCoord GetCenter() const
Definition: Projection.h:149
double GetAngle() const
Definition: Projection.h:176
void SetLinearInterpolationUsage(bool b)
Definition: Projection.h:571
double GetLon() const
Definition: Projection.h:158
double meterInMM
Number of on screen millimeters for one meter on the ground.
Definition: Projection.h:61
double scaleGradtorad
Precalculated scale*Gradtorad.
Definition: Projection.h:499
double lonOffset
Definition: Projection.h:496
double angle
Display rotation angle in radians, canvas clockwise.
Definition: Projection.h:48
Definition: Projection.h:491
double GetPixelSize() const
Definition: Projection.h:251
double scaledLatDeriv
precalculated derivation of "latToYPixel" function in projection center scaled by gradtorad * scale ...
Definition: Projection.h:501
bool IsValidFor(const GeoCoord &coord) const override
Definition: Projection.h:368
bool MoveRight(double pixel)
Definition: Projection.h:461
double latOffset
Definition: Projection.h:497
Definition: Projection.h:333
double angleNegSin
Definition: Projection.h:341
Magnification GetMagnification() const
Definition: Projection.h:200
bool CanBatch() const override
Definition: Projection.h:358
bool GeoIsIn(double lon, double lat) const
Definition: Projection.h:216
bool Set(const OSMTileId &tile, const Magnification &magnification, size_t width, size_t height)
Definition: Projection.h:539
Magnification magnification
Current magnification.
Definition: Projection.h:49
size_t GetHeight() const
Definition: Projection.h:192
double latMax
Latitude of the lower right corner of the image.
Definition: Projection.h:57
bool Set(const GeoCoord &coord, const Magnification &magnification, size_t width, size_t height)
Definition: Projection.h:374
size_t width
Width of image.
Definition: Projection.h:51
double GetMeterInPixel() const
Definition: Projection.h:259
Definition: Projection.h:43
double lonMax
Longitude of the lower right corner of the image.
Definition: Projection.h:56
double latMin
Latitude of the upper left corner of the image.
Definition: Projection.h:55
double scaledLatDeriv
precalculated derivation of "latToYPixel" function in projection center scaled by gradtorad * scale ...
Definition: Projection.h:347
bool MoveDown(double pixel)
Definition: Projection.h:451
double scale
Definition: Projection.h:344
double angleCos
Definition: Projection.h:340
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
static const double MinLat
Definition: Projection.h:352
double GetMeterInMM() const
Definition: Projection.h:267
double lonMin
Longitude of the upper left corner of the image.
Definition: Projection.h:54
double angleNegCos
Definition: Projection.h:342
bool CanBatch() const override
Definition: Projection.h:523
double ConvertPixelToWidth(double pixel) const
Definition: Projection.h:293
bool valid
projection is valid
Definition: Projection.h:494
double scale
Definition: Projection.h:498
static const double MaxLat
Definition: Projection.h:351
bool Set(const GeoCoord &coord, const Magnification &magnification, double dpi, size_t width, size_t height)
Definition: Projection.h:389
double lat
Latitude coordinate of the center of the image.
Definition: Projection.h:47
double lon
Longitude coordinate of the center of the image.
Definition: Projection.h:46
size_t GetWidth() const
Definition: Projection.h:184
size_t height
Height of image.
Definition: Projection.h:52
double GetDPI() const
Definition: Projection.h:208
bool IsLinearInterpolationEnabled() const
Definition: Projection.h:562
bool IsValid() const override
Definition: Projection.h:363
static const double MinLon
Definition: Projection.h:354
bool IsValid() const override
Definition: Projection.h:528
bool valid
projection is valid
Definition: Projection.h:336
GeoBox GetDimensions() const
Definition: Projection.h:233
bool Set(const GeoCoord &coord, double angle, const Magnification &magnification, size_t width, size_t height)
Definition: Projection.h:381
static const double MaxLon
Definition: Projection.h:353
bool GeoIsIn(double lonMin, double latMin, double lonMax, double latMax) const
Definition: Projection.h:224
double meterInPixel
Number of on screen pixel for one meter on the ground.
Definition: Projection.h:60
bool MoveLeft(double pixel)
Definition: Projection.h:456
double angleSin
Definition: Projection.h:339
double dpi
Screen DPI.
Definition: Projection.h:50
void GetDimensions(GeoBox &boundingBox) const
Definition: Projection.h:242
virtual bool CanBatch() const =0
void SetLinearInterpolationUsage(bool useLinearInterpolation)
Definition: Projection.h:475
bool IsLinearInterpolationEnabled() const
Definition: Projection.h:466
double GetLat() const
Definition: Projection.h:167
virtual bool GeoToPixel(const GeoCoord &coord, double &x, double &y) const =0
bool PixelToGeo(double x, double y, GeoCoord &coord) const
Definition: Projection.h:428
double scaleGradtorad
Precalculated scale*Gradtorad.
Definition: Projection.h:345
bool IsValidFor(const GeoCoord &coord) const override
Definition: Projection.h:533
double latOffset
Absolute and untransformed screen position of lat coordinate.
Definition: Projection.h:338
bool MoveUp(double pixel)
Definition: Projection.h:446
bool useLinearInterpolation
switch to enable linear interpolation of latitude to pixel computation
Definition: Projection.h:348