예제 #1
0
static void dump_contour(const VpfContour &c, ofstream &stream)
{
  int nPoints = c.getPointCount();

  for (int i = 0; i < nPoints; i++)
    {
      dump_point(c.getPoint(i), stream);
    }
}
예제 #2
0
파일: garmin_img.c 프로젝트: zintor/navit
static void
dump_region_item(struct subdivision *sub, struct file *rgn, struct map_rect_priv *mr)
{
	int offset,item_offset,i,j;
	unsigned short count=0;
	unsigned short *offsets[4];
	unsigned short *file_offsets;
	struct rgn_point *pnt;

	offset=triple_u(&sub->rgn_offset)+mr->rgn_hdr->offset_len.offset;
	file_offsets=file_read(rgn, offset, 90*sizeof(unsigned short));
	printf("0x%x ", offset); dump_hex(file_offsets, 90);
	for (i=0 ; i < 4 ; i++) {
		printf("i=%d\n", i);
		if (sub->types & (0x10 << i)) {
			if (count) {	
				offsets[i]=&file_offsets[count-1];
			} else
				offsets[i]=&count;
			count++;
		} else
			offsets[i]=NULL;
		
	}
	count--;
	count*=2;
	for (i=0 ; i < 4 ; i++) {
		printf("i=%d\n", i);
		if (offsets[i]) {
			printf("offset[%d]=0x%x(%d)\n", i, *offsets[i], *offsets[i]);
			switch (i) {
			case 0:
				printf("point\n");
				break;
			case 1:
				printf("indexed point\n");
				break;
			case 2:
				printf("polyline\n");
				break;
			case 3:
				printf("polygon\n");
				break;
			}
			item_offset=offset+*offsets[i];
			switch (i) {
			case 0:
			case 1:
				for (j = 0 ; j < 10 ; j++) {
					struct coord_geo g;
					char buffer[1024];
					double conv=180.0/(1UL<<23);
					pnt=file_read(rgn, item_offset, sizeof(*pnt)*20);
					// printf("0x%x ", item_offset); dump_hex(pnt, 32);
					dump_point(pnt);
					g.lng=(triple(&sub->center.lng)+(pnt->lng_delta << shift))*conv;
					g.lat=(triple(&sub->center.lat)+(pnt->lat_delta << shift))*conv;
					printf("%f %f\n", g.lng, g.lat);
					coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,
						     buffer,sizeof(buffer));
					printf("%s\n", buffer);
					dump_label_offset(mr, triple_u(&pnt->lbl_offset));
					if (pnt->info & 0x80) 
						item_offset+=sizeof(*pnt);
					else
						item_offset+=sizeof(*pnt)-1;
				}
			}
		} else {
			printf("offset[%d] doesn't exist\n", i);
		}
	}
	file_free(file_offsets);
}
예제 #3
0
static void dump_line(const VpfLine &l, ofstream &stream)
{
  int nPoints = l.getPointCount();
  for (int i = 0; i < nPoints; i++)
    dump_point(l.getPoint(i), stream);
}
예제 #4
0
int main(int argc, char** argv)
{
  cerr << "Starte mit einlesen\n";
  if(argc <= 4)
    {
      cerr << "Usage: vpf_importer <DataBase> <Library> <Coverage(id)> <Feature(id)> [<first Element(id)>]\n";
      return 1;
    }

  // Zielverzeichnis der Kartendateien ...
  string outDir((string)"/data/KartenDaten/VPF-Daten/heiner/" + argv[2] + "/");

  VpfRectangle bounds;
  bounds.minX = -180.0;
  bounds.maxX = 180.0;

  bounds.minY = -90.0;
  bounds.maxY = 90.0;

  VpfDataBase db( argv[1] );

  cout << "Number of libraries: " << db.getLibraryCount() << endl;

  VpfLibrary lib( db.getLibrary(argv[2]) );

  cout << "Number of coverages: " << lib.getCoverageCount() << endl;

  int coverCount = lib.getCoverageCount();

  cout << "<->\n";

  int cID(0), fID(0), idStart(0);

  sscanf(argv[3], "%d", &cID);
  sscanf(argv[4], "%d", &fID);

  if(argc > 5)
    {
      sscanf(argv[5], "%d", &idStart);
    }

  VpfCoverage cover(lib.getCoverage(cID));
  int featureCount = cover.getFeatureCount();

  cout << "Coverage: " << cover.getName() << " (" << cID << ") Features: "
       << cover.getFeatureCount() << endl;

  VpfFeature feature(cover.getFeature(fID));
  string fileName((string)argv[1] + "/" + (string)argv[2] + "/" +
      (string)cover.getName() + "/" + (string)feature.getName());

  // Ausgabe-Datei öffnen:
  string outFileName((string)cover.getName() + "_" + (string)feature.getName());
  string idFileName = outDir + "/IDS/" + outFileName + ".id";
  outFileName = outDir + outFileName;

  ofstream outFile;
  ifstream idFile;

  cout << "\n";
  cout << "  Öffne Ausgabedatei: " << outFileName << " ...";
/*
  idFile.open(idFileName.c_str(), ios::in);
  if(!idFile)
    {
      cerr << "FEHLER! bei ID File\n" << idFileName.c_str() << endl;
      return 0;
    }
*/
  outFile.open(outFileName.c_str(), ios::out | ios::app );
  if(!outFile)
    {
      cerr << "FEHLER!\n";
      return 1;
    }
  else
    {
      cout << "fertig\n";
    }

  cout << endl;
  cout << "  Bearbeite " << cover.getName() << " (" << cID << ") "
       << feature.getName() << " (" << fID << ")\n";

  switch(feature.getTopologyType())
    {
      case VpfFeature::POINT:
        fileName += ".pft";
        break;
      case VpfFeature::LINE:
        fileName += ".lft";
        break;
      case VpfFeature::POLYGON:
        fileName += ".aft";
        break;
      case VpfFeature::LABEL:
        fileName += ".tft";
        break;
        default:
      throw VpfException("Unsupported topology type");
    }

  VpfTable table(fileName);

  dump_table_header(table, outFile);

  char p[20];
  int id(-1), oldID(-1), rowLoop;

  int rowCount = table.getRowCount();
  int colCount = table.getColumnCount();
  int topologyType = feature.getTopologyType();

  for(int rowLoop = idStart; rowLoop < table.getRowCount(); rowLoop++)
    {
      outFile << "[NEW]\n";

      std::string header = "";
      for(int colLoop = 0; colLoop < colCount; colLoop++)
        {
          outFile << table.getColumnDecl(colLoop).getName() << "="
                  << table.getValue(rowLoop, colLoop) << endl;

        }

      try
        {
          //cout << "\r";
          cout << "id: ";
          cout.width(10);
          cout << rowLoop << "  von ";
          cout.width(10);
          cout << rowCount << " ( ";
          cout.precision(2);
          cout.width(4);
          cout.setf(ios::fixed);
          cout << (float)((float)rowLoop / (float)rowCount * 100) << "% )\n";

          switch(topologyType)
            {
              case VpfFeature::POINT:
                dump_point(feature.getPoint(rowLoop), outFile);
                break;
              case VpfFeature::LINE:
                dump_line(feature.getLine(rowLoop), outFile);
                break;
              case VpfFeature::POLYGON:
                dump_polygon(feature.getPolygon(rowLoop), outFile, table, rowLoop);
                break;
              case VpfFeature::LABEL:
                dump_label(feature.getLabel(rowLoop), outFile);
                break;
              default:
                throw VpfException("Unsupported topology type");
            }
        }
      catch(VpfException &e)
        {
          cerr << "Fehler: " << e.getMessage() << endl;
        }

      outFile << "[END]\n";

    }

  outFile.close();

  cout << endl;
  return 0;

}