示例#1
0
/**
 * Specify an alternate directory for the PROJ.4 grid files
 * (this should augment the PROJ.4 compile-time path)
 *
 * It's main purpose is to allow Win32 PROJ.4 installations
 * to find a set grid shift files, although other platforms
 * may find this useful too.
 *
 * Note that we currently ignore this on PostgreSQL < 8.0
 * since the method of determining the current installation
 * path are different on older PostgreSQL versions.
 */
void SetPROJ4LibPath(void)
{
	char *path;
	const char **proj_lib_path;

	if (!IsPROJ4LibPathSet) {

		/*
		 * Get the sharepath and append /contrib/postgis/proj to form a suitable
		 * directory in which to store the grid shift files
		 */
		proj_lib_path = palloc(sizeof(char *));
		path = palloc(MAXPGPATH);
		*proj_lib_path = path;

		get_share_path(my_exec_path, path);
		strncat(path, "/contrib/postgis/proj", MAXPGPATH - strlen(path) - 1);

		/* Set the search path for PROJ.4 */
		pj_set_searchpath(1, proj_lib_path);

		/* Ensure we only do this once... */
		IsPROJ4LibPathSet = true;
	}
}
bool wxGISApplicationEx::SetupSys(const wxString &sSysPath)
{
    if(!wxGISApplication::SetupSys(sSysPath))
        return false;
#ifdef __WINDOWS__
	wxString sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("gdal")) + wxFileName::GetPathSeparator();
	CPLSetConfigOption("GDAL_DATA", sGdalDataDir.ToUTF8() );
    #ifdef wxGIS_USE_PROJ
        sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("proj")) + wxFileName::GetPathSeparator();
        //CPLSetConfigOption("PROJ_LIB", sGdalDataDir.mb_str(wxConvUTF8) );
        CPLString pszPROJ_LIB(sGdalDataDir.mb_str(wxConvUTF8));
        const char *path = pszPROJ_LIB.c_str();
        pj_set_searchpath(1, &path);
    #endif // wxGIS_USE_PROJ
#endif // __WINDOWS__

#ifdef __UNIX__
    wxString sGdalDataGCS = wxString::Format(wxT("/usr/share/gdal/%s/gcs.csv"), GDALVersionInfo("RELEASE_NAME"));
    if(!wxFileName::FileExists(sGdalDataGCS))
    {
        sGdalDataGCS = wxString(wxT("/usr/share/gdal/gcs.csv"));
        if(!wxFileName::FileExists(sGdalDataGCS))
        {
            sGdalDataGCS = wxString::Format(wxT("/usr/local/share/gdal/%s/gcs.csv"), GDALVersionInfo("RELEASE_NAME"));
            if(!wxFileName::FileExists(sGdalDataGCS))
            {
                sGdalDataGCS = wxString(wxT("/usr/local/share/gdal/gcs.csv"));
                if(!wxFileName::FileExists(sGdalDataGCS))
                {
                    return false;
                }
            }
        }
    }

    wxFileName Name(sGdalDataGCS);
    CPLSetConfigOption("GDAL_DATA", Name.GetPath().ToUTF8() );
    //TODO: set path to proj lib
    #ifdef wxGIS_USE_PROJ
    #endif // wxGIS_USE_PROJ
#endif //__UNIX__

#ifndef CPL_RECODE_ICONV
    //the gdal compiled without iconv support
    //we should recode string by ourselthes
    CPLSetConfigOption("SHAPE_ENCODING", CPL_ENC_ASCII);
    CPLSetConfigOption("DXF_ENCODING", CPL_ENC_ASCII);
#endif //CPL_RECODE_ICONV
    return true;
}
示例#3
0
Projection::Projection(void)
: p(new ProjectionPrivate)
{
#if defined(Q_OS_WIN) && !defined(_MOBILE)
    QString pdir(QDir::toNativeSeparators(qApp->applicationDirPath() + "/" STRINGIFY(SHARE_DIR) "/proj"));
    const char* proj_dir = pdir.toUtf8().constData();
//    const char* proj_dir = "E:\\cbro\\src\\merkaartor-devel\\binaries\\bin\\share\\proj";
    pj_set_searchpath(1, &proj_dir);
#endif // Q_OS_WIN

#ifndef _MOBILE
    theProj = NULL;
    p->theWGS84Proj = Projection::getProjection("+proj=longlat +ellps=WGS84 +datum=WGS84");
    setProjectionType(M_PREFS->getProjectionType());
#endif
}
示例#4
0
bool wxGISServer::SetupSys(const wxString &sSysPath)
{
	//setup sys dir
	if(!wxDirExists(sSysPath))
	{
		wxLogError(wxString::Format(_("wxGISServer: System folder is absent! Lookup path '%s'"), sSysPath.c_str()));
		return false;
	}

	wxString sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("gdal")) + wxFileName::GetPathSeparator();
	CPLSetConfigOption("GDAL_DATA", sGdalDataDir.mb_str(wxConvUTF8) );
#ifdef HAVE_PROJ
	sGdalDataDir = sSysPath + wxFileName::GetPathSeparator() + wxString(wxT("proj")) + wxFileName::GetPathSeparator();
	//CPLSetConfigOption("PROJ_LIB", sGdalDataDir.mb_str(wxConvUTF8) );
    CPLString pszPROJ_LIB(sGdalDataDir.mb_str(wxConvUTF8));
    const char *path = pszPROJ_LIB.c_str();
    pj_set_searchpath(1, &path);
#endif
    return true;
}
示例#5
0
文件: main.cpp 项目: djdarkbeat/ZTopo
int main(int argc, char **argv)
{
  qRegisterMetaType<Cache::Key>("Key");
  qRegisterMetaType<Tile>("Tile");
  qRegisterMetaType<qkey>("qkey");

  QCoreApplication::setOrganizationName("ZTopo");
  QCoreApplication::setApplicationName("ZTopo");

  QApplication app(argc, argv);

#if defined(Q_WS_MAC)
  QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus);
  // Mac OS specific code to find resources within a bundle
  CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
  CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef,
                                                kCFURLPOSIXPathStyle);
  const char *pathPtr = CFStringGetCStringPtr(macPath,
                                              CFStringGetSystemEncoding());
  if (!pathPtr) {
    qFatal("Could not find Mac application bundle path!");
  }
  QString rootPath = QString(pathPtr) % "/Contents/Resources/";
  QByteArray rootPathArray = QString(rootPath % "proj4").toLatin1();
  //qDebug("proj root '%s'\n", rootPathArray.data());

  const char *path[] = { rootPathArray.data() };
  pj_set_searchpath(1, (const char **)&path);
  CFRelease(appUrlRef);
  CFRelease(macPath);  
#elif defined(Q_WS_WIN)
  /* On Windows, use the proj4 subdirectory of the directory containing the 
     application */
  QString projPath = app.applicationDirPath() % "/proj4";
  //qDebug() << "proj root" << projPath;
  const char *path[] = { QDir::toNativeSeparators(projPath).toLatin1().data() };
  pj_set_searchpath(1, (const char **)&path);
#endif

  // On other operating systems, we assume the proj4 library can find its own datum
  // shift grids.

  QSettings settings;
  QString cachePath = settings.value("cachePath", 
      QDesktopServices::storageLocation(QDesktopServices::CacheLocation)).toString();
  QDir::current().mkpath(cachePath);

  QNetworkAccessManager networkManager;
  QNetworkDiskCache diskCache;
  diskCache.setCacheDirectory(cachePath % "/meta");
  diskCache.setMaximumCacheSize(maxDiskCacheSize);
  networkManager.setCache(&diskCache);
 

  RootData rootData(&networkManager);

  if (rootData.maps().size() == 0) {
    qFatal("No maps in root data file!");
  }
  Map *map = rootData.maps().values()[0];

  int maxMemCache = settings.value(settingMemCache, 64).toInt();
  int maxDiskCache = settings.value(settingDiskCache, 200).toInt();
  Cache::Cache tileCache(map, networkManager, maxMemCache, maxDiskCache, cachePath);
  MapRenderer renderer(map, tileCache);
  MainWindow *window = new MainWindow(rootData, map, &renderer, tileCache, 
                                      networkManager);

  window->show();

  if (rootData.majorVersion() > majorVersion || 
      (rootData.majorVersion() == majorVersion 
       && rootData.minorVersion() > minorVersion)) {
    QMessageBox mbox;
    mbox.setText("A new version of ZTopo is available.");
    mbox.setInformativeText(QString("A new version of ZTopo (%1.%2) is available for download. Would you like to open the ZTopo home page?").arg(rootData.majorVersion()).arg(rootData.minorVersion()));
    mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    mbox.setDefaultButton(QMessageBox::Yes);
    int ret = mbox.exec();
    if (ret == QMessageBox::Yes) {
      QDesktopServices::openUrl(QUrl(rootData.homePageUrl()));
    }
  }

  return app.exec();
}