Skip to content
Permalink
Browse files
Added options to graticule builder to allow you to define origin and …
…enpoints and to set the graticule size at < 1 degree. Note that there is little error checking in there still, so putting in dodgy numbers may cause qgis to crash.

git-svn-id: http://svn.osgeo.org/qgis/trunk@2223 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 9, 2004
1 parent 62e2c7c commit aa5b4c530c98673498e6cdf43120167a14704d12
Showing with 216 additions and 97 deletions.
  1. +6 −0 ChangeLog
  2. +1 −1 configure.in
  3. +31 −10 plugins/grid_maker/graticulecreator.cpp
  4. +15 −2 plugins/grid_maker/graticulecreator.h
  5. +19 −2 plugins/grid_maker/plugingui.cpp
  6. +144 −82 plugins/grid_maker/pluginguibase.ui
@@ -3,6 +3,12 @@ ChangeLog,v 1.200 2004/10/21 17:27:35 mcoletti Exp
------------------------------------------------------------------------------
Version 0.6 'Simon' .... development version

2004-11-09 [timlinux] 0.5.0devel21
** Added options to graticule builder to allow you to define origin and
enpoints and to set the graticule size at < 1 degree. Note that there is
little error checking in there still, so putting in dodgy numbers may cause
qgis to crash.

2004-11-04 [timlinux] 0.5.0devel20
** Added scale dependent visibility support to both raster and vector layers.

@@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=5
MICRO_VERSION=0
EXTRA_VERSION=20
EXTRA_VERSION=21
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
@@ -4,7 +4,14 @@
#include <iostream>
#include <qfileinfo.h>
#include <qstringlist.h>
GraticuleCreator::GraticuleCreator(QString theOutputFileName, double theXIntervalDouble, double theYIntervalDouble)
GraticuleCreator::GraticuleCreator(QString theOutputFileName,
double theXIntervalDouble,
double theYIntervalDouble,
double theXOriginDouble,
double theYOriginDouble,
double theXEndPointDouble,
double theYEndPointDouble
)
{
std::cout << "GraticuleCreator constructor called with " << theOutputFileName
<< " for output file and " << theXIntervalDouble << "," << theYIntervalDouble << " for x,y interval " << std::endl;
@@ -15,7 +22,14 @@ GraticuleCreator::GraticuleCreator(QString theOutputFileName, double theXInterva
myShapeHandle = createShapeFile(theOutputFileName);
//test the write point routine....
//generatePoints(theInputFileName,myDbfHandle,myShapeHandle);
generateGraticule(myDbfHandle,myShapeHandle,theXIntervalDouble,theYIntervalDouble);
generateGraticule(myDbfHandle,
myShapeHandle,
theXIntervalDouble,
theYIntervalDouble,
theXOriginDouble,
theYOriginDouble,
theXEndPointDouble,
theYEndPointDouble);
DBFClose( myDbfHandle );
SHPClose( myShapeHandle );
return;
@@ -105,26 +119,33 @@ void GraticuleCreator::writeLine(SHPHandle theShapeHandle,
}

//TODO: check for rediculous intervals!
void GraticuleCreator::generateGraticule(DBFHandle theDbfHandle, SHPHandle theShapeHandle,double theXIntervalDouble,double theYIntervalDouble)
void GraticuleCreator::generateGraticule(DBFHandle theDbfHandle,
SHPHandle theShapeHandle,
double theXIntervalDouble,
double theYIntervalDouble,
double theXOriginDouble,
double theYOriginDouble,
double theXEndPointDouble,
double theYEndPointDouble)
{

int myRecordInt=0;
//create the arrays for storing the coordinates
double * myXArrayDouble;
double * myYArrayDouble;
myXArrayDouble = (double *)malloc(2 * sizeof(double));
myXArrayDouble = (double *)malloc(2 * sizeof(double)); //2=no vertices
myYArrayDouble = (double *)malloc(2 * sizeof(double));

//
//Longitude loop
//
for (double myXDouble=-180.0;myXDouble <=180.0;myXDouble+=theXIntervalDouble)
for (double myXDouble = theXOriginDouble;myXDouble <=theXEndPointDouble;myXDouble+=theXIntervalDouble)
{

myXArrayDouble[0]=myXDouble;
myXArrayDouble[1]=myXDouble;
myYArrayDouble[0]=-90.0;
myYArrayDouble[1]=90.0;
myYArrayDouble[0]=theYOriginDouble;
myYArrayDouble[1]=theYEndPointDouble;

writeDbfRecord(theDbfHandle,myRecordInt,"testing");
writeLine(theShapeHandle, myRecordInt, 2, myXArrayDouble, myYArrayDouble); //2=no vertices
@@ -135,11 +156,11 @@ void GraticuleCreator::generateGraticule(DBFHandle theDbfHandle, SHPHandle theSh
//
//Latitude loop
//
for (double myYDouble=-90.0;myYDouble<=90.0;myYDouble+=theYIntervalDouble)
for (double myYDouble=theYOriginDouble;myYDouble<=theYEndPointDouble;myYDouble+=theYIntervalDouble)
{

myXArrayDouble[0]=-180.0;
myXArrayDouble[1]=180.0;
myXArrayDouble[0]=theXOriginDouble;
myXArrayDouble[1]=theXEndPointDouble;
myYArrayDouble[0]=myYDouble;
myYArrayDouble[1]=myYDouble;

@@ -11,7 +11,13 @@
class GraticuleCreator
{
public:
GraticuleCreator(QString theOutputFileName, double theXIntervalDouble, double theYIntervalDouble);
GraticuleCreator(QString theOutputFileName,
double theXIntervalDouble,
double theYIntervalDouble,
double theXOriginDouble,
double theYOriginDouble,
double theXEndPointDouble,
double theYEndPointDouble);
~GraticuleCreator() {};
DBFHandle GraticuleCreator::createDbf (QString theDbfName ) ;
SHPHandle GraticuleCreator::createShapeFile(QString theFileName );
@@ -22,7 +28,14 @@ class GraticuleCreator
int theCoordinateCountInt,
double * theXArrayDouble,
double * theYArrayDouble );
void generateGraticule(DBFHandle theDbfHandle, SHPHandle theShapeHandle,double theXIntervalDouble,double theYIntervalDouble);
void generateGraticule(DBFHandle theDbfHandle,
SHPHandle theShapeHandle,
double theXIntervalDouble,
double theYIntervalDouble,
double theXOriginDouble,
double theYOriginDouble,
double theXEndPointDouble,
double theYEndPointDouble);
void generatePoints (QString theInputFileName, DBFHandle theDbfHandle, SHPHandle theShapeHandle);

private:
@@ -14,7 +14,6 @@
//qt includes
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qfile.h>
@@ -39,7 +38,25 @@ void PluginGui::pbnOK_clicked()
{
//check input file exists
//
GraticuleCreator * myGraticuleCreator = new GraticuleCreator(leOutputShapeFile->text(),spinLongInterval->value(),spinLatInterval->value());
std::cout << "GrativuleCreator called with: " <<
leOutputShapeFile->text() <<
leLongitudeInterval->text() <<
leLatitudeInterval->text() <<
leOriginLongitude->text() <<
leOriginLatitude->text() <<
leEndPointLongitude->text() <<
leEndPointLatitude->text()
<< std::endl;

GraticuleCreator * myGraticuleCreator = new GraticuleCreator(
leOutputShapeFile->text(),
leLongitudeInterval->text().toDouble(),
leLatitudeInterval->text().toDouble(),
leOriginLongitude->text().toDouble(),
leOriginLatitude->text().toDouble(),
leEndPointLongitude->text().toDouble(),
leEndPointLatitude->text().toDouble()
);
//
// If you have a produced a raster layer using your plugin, you can ask qgis to
// add it to the view using:

0 comments on commit aa5b4c5

Please sign in to comment.