|
From: <joh...@ie...> - 2000-03-14 19:48:13
|
Patch: vhclmaps-000314-johnston-012
For: vhclmaps-0.7.4
Author: joh...@us...
Subject: MapFiles::valid(), handle more Vpf database anomalies
Requires: ivtools-000314-johnston-031
This is an intermediate patch to vhclmaps-0.7.4. To apply, cd to the
top-level directory of the vhclmaps source tree (the directory with src
and config subdirs), and apply like this:
patch -p0 <ThisFile
Summary of Changes:
- add a MapFiles::valid() (the base class of the
MapDatabase/MapLibrary/MapCoverage/MapFClass/MapFeature hierarchy)
which is by default true, but any subclass can clear if they have
problem constructing themselves.
- fix segfault that occurs when the pathnames and names for a Vpf
database (library/coverage/feature-class) are not incorrect.
- fix problem with Vpf database that has a negative (or
outrageously large) edge_id in the first row of a face table.
- fix problems with Vpf databases that use "id" for a feature
table, instead of a col name that embeds the feature table name in it.
Index: top_vhclmaps/configure
diff -c top_vhclmaps/configure:1.3 top_vhclmaps/configure:1.4
*** top_vhclmaps/configure:1.3 Thu Feb 17 22:39:14 2000
--- ./configure Tue Mar 14 22:51:49 2000
***************
*** 2022,2028 ****
echo writing \"CPU = `make CPU`\"
echo CPU = `make CPU` >>config/config.mk
echo
! echo "now do a \"make World\""
echo
--- 2022,2028 ----
echo writing \"CPU = `make CPU`\"
echo CPU = `make CPU` >>config/config.mk
echo
! echo "now do a \"make\""
echo
Index: top_vhclmaps/configure.in
diff -c top_vhclmaps/configure.in:1.5 top_vhclmaps/configure.in:1.6
*** top_vhclmaps/configure.in:1.5 Thu Feb 17 22:39:14 2000
--- ./configure.in Tue Mar 14 22:51:50 2000
***************
*** 411,417 ****
echo writing \"CPU = `make CPU`\"
echo CPU = `make CPU` >>config/config.mk
echo
! echo "now do a \"make World\""
echo
--- 411,417 ----
echo writing \"CPU = `make CPU`\"
echo CPU = `make CPU` >>config/config.mk
echo
! echo "now do a \"make\""
echo
Index: Map/mapfiles.c
diff -c Map/mapfiles.c:1.1 Map/mapfiles.c:1.2
*** Map/mapfiles.c:1.1 Mon Aug 2 13:52:40 1999
--- src/Map/mapfiles.c Tue Mar 14 22:51:52 2000
***************
*** 45,50 ****
--- 45,52 ----
} else
_path = nil;
+ /* start with the assumption everythings ok */
+ _valid = true;
}
MapFiles::~MapFiles () {
Index: Map/mapfiles.h
diff -c Map/mapfiles.h:1.1 Map/mapfiles.h:1.2
*** Map/mapfiles.h:1.1 Mon Aug 2 13:52:40 1999
--- src/Map/mapfiles.h Tue Mar 14 22:51:52 2000
***************
*** 43,48 ****
--- 43,50 ----
virtual const char* description() const;
+ boolean valid() { return _valid; }
+
protected:
boolean initialized() const {return false;}
***************
*** 51,56 ****
--- 53,59 ----
protected:
char* _name;
char* _path;
+ boolean _valid;
};
#endif /* defined(mapfiles_h) */
Index: VpfUtil/vpftable.c
diff -c VpfUtil/vpftable.c:1.1 VpfUtil/vpftable.c:1.2
*** VpfUtil/vpftable.c:1.1 Mon Aug 2 13:52:45 1999
--- src/VpfUtil/vpftable.c Tue Mar 14 22:51:54 2000
***************
*** 810,817 ****
#endif
*/
free(table.path);
! fclose(table.fp);
! table.fp = NULL;
return table;
}
--- 810,819 ----
#endif
*/
free(table.path);
! if (table.fp) {
! fclose(table.fp);
! table.fp = NULL;
! }
return table;
}
Index: Vpf/vpfdb.c
diff -c Vpf/vpfdb.c:1.1 Vpf/vpfdb.c:1.2
*** Vpf/vpfdb.c:1.1 Mon Aug 2 13:52:48 1999
--- src/Vpf/vpfdb.c Tue Mar 14 22:51:57 2000
***************
*** 45,52 ****
}
void VpfDatabase::init() {
! producer();
! init_libraries();
}
VpfLibrary* VpfDatabase::library(unsigned libnum) const {
--- 45,54 ----
}
void VpfDatabase::init() {
! if(!producer())
! _valid = false;
! else
! init_libraries();
}
VpfLibrary* VpfDatabase::library(unsigned libnum) const {
***************
*** 66,71 ****
--- 68,74 ----
strcat(dhtpath, "/dht.");
table = vpf_open_table(dhtpath, disk, "rb", NULL);
if (!table.fp) {
+ ((VpfDatabase*)this)->_valid = false;
return nil;
}
else {
Index: Vpf/vpffclass.c
diff -c Vpf/vpffclass.c:1.1 Vpf/vpffclass.c:1.2
*** Vpf/vpffclass.c:1.1 Mon Aug 2 13:52:48 1999
--- src/Vpf/vpffclass.c Tue Mar 14 22:51:57 2000
***************
*** 989,999 ****
face_rec = read_face( face_id, facetable );
ring_rec = read_ring( face_rec.ring, ringtable );
! MapFace* mf = outline_polygon_loop( row, face_id, ring_rec.edge, edgetable, ftype);
! VpfFeature* vf = new VpfFeature((VpfFeatureClass*)this,feat_id,MapFeature::AreaType,
ftype,row);
! vf->face_primitive(mf);
! return vf;
}
/* Inspired by DosVpfviews\'s table_pos */
--- 989,1002 ----
face_rec = read_face( face_id, facetable );
ring_rec = read_ring( face_rec.ring, ringtable );
! if (ring_rec.edge>0) {
! MapFace* mf = outline_polygon_loop( row, face_id, ring_rec.edge, edgetable, ftype);
! VpfFeature* vf = new VpfFeature((VpfFeatureClass*)this,feat_id,MapFeature::AreaType,
ftype,row);
! vf->face_primitive(mf);
! return vf;
! } else
! return nil;
}
/* Inspired by DosVpfviews\'s table_pos */
Index: Vpf/vpftiledfc.c
diff -c Vpf/vpftiledfc.c:1.1 Vpf/vpftiledfc.c:1.2
*** Vpf/vpftiledfc.c:1.1 Mon Aug 2 13:52:48 1999
--- src/Vpf/vpftiledfc.c Tue Mar 14 22:51:57 2000
***************
*** 162,167 ****
--- 162,171 ----
strupr(colname);
strcat(colname, "_ID");
long int colpos = table_pos(colname, table);
+ if (colpos<0) {
+ strcpy(colname, "id");
+ colpos = table_pos(colname, table);
+ }
long int n;
#if 0
row = get_row(1, table);
***************
*** 291,296 ****
--- 295,304 ----
strupr(colname);
strcat(colname, "_ID");
long int face_feat_pos = table_pos(colname, facetable);
+ if (face_feat_pos<0) {
+ strcpy(colname, "id");
+ face_feat_pos = table_pos(colname, facetable);
+ }
ringtable = vpf_open_table(ringpath,disk,"rb",NULL);
if (!ringtable.fp) return;
long ring_id_pos = table_pos("ID", ringtable);
Index: VpfUnidraw/vpfcomps.c
diff -c VpfUnidraw/vpfcomps.c:1.1 VpfUnidraw/vpfcomps.c:1.2
*** VpfUnidraw/vpfcomps.c:1.1 Mon Aug 2 13:53:11 1999
--- src/VpfUnidraw/vpfcomps.c Tue Mar 14 22:52:02 2000
***************
*** 330,356 ****
}
else for (i = 0; i < tfc->nfeats(tileid); i++) {
MapFeature* vf = tfc->feature(tileid,i);
! PJ* pj = ((MapShowCmd*)cmd)->GetProjection();
! if (pj)
! project_feature(pj, vf);
! MapFeatureComp* mfc = new MapFeatureComp(vf);
! ((VpfFeature*)vf)->graphic(mfc);
!
! // create companion point comp for text comp
! if (vf->type() == MapFeature::TextType) {
! MapFeature* pf = new MapFeature
! (vf->feature_class(), -1, MapFeature::PointType);
! MapPoint* pp = new MapPoint(pf);
! float px = vf->text_primitive()->xorigin();
! float py = vf->text_primitive()->yorigin();
! pp->insert_points(1, &px, &py);
! pf->point_primitive(pp);
! MapFeatureComp* pfc = new MapFeatureComp(pf);
! _tcomps[tileid]->Append(pfc);
! mfc->pointcomp(pfc);
}
-
- _tcomps[tileid]->Append(mfc);
}
Append(_tcomps[tileid]);
}
--- 330,359 ----
}
else for (i = 0; i < tfc->nfeats(tileid); i++) {
MapFeature* vf = tfc->feature(tileid,i);
! if (vf) {
!
! PJ* pj = ((MapShowCmd*)cmd)->GetProjection();
! if (pj)
! project_feature(pj, vf);
! MapFeatureComp* mfc = new MapFeatureComp(vf);
! ((VpfFeature*)vf)->graphic(mfc);
!
! // create companion point comp for text comp
! if (vf->type() == MapFeature::TextType) {
! MapFeature* pf = new MapFeature
! (vf->feature_class(), -1, MapFeature::PointType);
! MapPoint* pp = new MapPoint(pf);
! float px = vf->text_primitive()->xorigin();
! float py = vf->text_primitive()->yorigin();
! pp->insert_points(1, &px, &py);
! pf->point_primitive(pp);
! MapFeatureComp* pfc = new MapFeatureComp(pf);
! _tcomps[tileid]->Append(pfc);
! mfc->pointcomp(pfc);
! }
!
! _tcomps[tileid]->Append(mfc);
}
}
Append(_tcomps[tileid]);
}
Index: MapServ/mapfunc.c
diff -c MapServ/mapfunc.c:1.1 MapServ/mapfunc.c:1.2
*** MapServ/mapfunc.c:1.1 Mon Aug 2 13:53:21 1999
--- src/MapServ/mapfunc.c Tue Mar 14 22:52:05 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1997-1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 90,95 ****
--- 91,104 ----
#include <strstream.h>
#include <stdio.h>
+ #include <ComUtil/comutil.h>
+ static int PointFeature_symid = symbol_add("PointFeature");
+ static int NodeFeature_symid = symbol_add("NodeFeature");
+ static int LineFeature_symid = symbol_add("LineFeature");
+ static int AreaFeature_symid = symbol_add("AreaFeature");
+ static int FeatureClass_symid = symbol_add("FeatureClass");
+ static int ComponentView_symid = symbol_add("ComponentView");
+
/*****************************************************************************/
MapFunc::MapFunc(ComTerp* comterp) : ComFunc(comterp) {
***************
*** 226,232 ****
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 235,241 ----
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 267,273 ****
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 276,282 ----
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 305,311 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = POINT_FEATURE;
push_stack(result);
}
--- 314,320 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = PointFeature_symid;
push_stack(result);
}
***************
*** 342,348 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = LINE_FEATURE;
push_stack(result);
}
--- 351,357 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = LineFeature_symid;
push_stack(result);
}
***************
*** 379,385 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = AREA_FEATURE;
push_stack(result);
}
--- 388,394 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = AreaFeature_symid;
push_stack(result);
}
***************
*** 410,416 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = NODE_FEATURE;
push_stack(result);
}
--- 419,425 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = NodeFeature_symid;
push_stack(result);
}
***************
*** 422,428 ****
void PolygonAreaFunc::execute() {
ComValue mf(stack_arg(0));
reset_stack();
! if (mf.type() == ComValue::ObjectType && mf.obj_type_val() == AREA_FEATURE) {
ComponentView* view = (ComponentView*)mf.obj_val();
MapFeatureComp* fcomp = (MapFeatureComp*)view->GetSubject();
MapFeature* feat = fcomp->feature();
--- 431,437 ----
void PolygonAreaFunc::execute() {
ComValue mf(stack_arg(0));
reset_stack();
! if (mf.type() == ComValue::ObjectType && mf.obj_type_val() == AreaFeature_symid) {
ComponentView* view = (ComponentView*)mf.obj_val();
MapFeatureComp* fcomp = (MapFeatureComp*)view->GetSubject();
MapFeature* feat = fcomp->feature();
***************
*** 449,455 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 458,464 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 476,482 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = fcview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 485,491 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = fcview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 490,498 ****
ComValue pt2(stack_arg(1));
reset_stack();
if (pt1.type() == ComValue::ObjectType &&
! pt1.obj_type_val() == POINT_FEATURE &&
pt2.type() == ComValue::ObjectType &&
! pt2.obj_type_val() == POINT_FEATURE) {
ComponentView* view1 = (ComponentView*)pt1.obj_val();
MapFeatureComp* fcomp1 = (MapFeatureComp*)view1->GetSubject();
MapFeature* feat1 = fcomp1->feature();
--- 499,507 ----
ComValue pt2(stack_arg(1));
reset_stack();
if (pt1.type() == ComValue::ObjectType &&
! pt1.obj_type_val() == PointFeature_symid &&
pt2.type() == ComValue::ObjectType &&
! pt2.obj_type_val() == PointFeature_symid) {
ComponentView* view1 = (ComponentView*)pt1.obj_val();
MapFeatureComp* fcomp1 = (MapFeatureComp*)view1->GetSubject();
MapFeature* feat1 = fcomp1->feature();
***************
*** 525,531 ****
ComValue ln(stack_arg(1));
reset_stack();
! if (pt.obj_type_val() == POINT_FEATURE && ln.obj_type_val() == LINE_FEATURE){
ComponentView* ptview = (ComponentView*)pt.obj_val();
ComponentView* lnview = (ComponentView*)ln.obj_val();
MapFeatureComp* ptcomp = (MapFeatureComp*)ptview->GetSubject();
--- 534,540 ----
ComValue ln(stack_arg(1));
reset_stack();
! if (pt.obj_type_val() == PointFeature_symid && ln.obj_type_val() == LineFeature_symid){
ComponentView* ptview = (ComponentView*)pt.obj_val();
ComponentView* lnview = (ComponentView*)ln.obj_val();
MapFeatureComp* ptcomp = (MapFeatureComp*)ptview->GetSubject();
***************
*** 577,583 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = rview;
! result.obj_type_ref() = POINT_FEATURE;
push_stack(result);
}
else
--- 586,592 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = rview;
! result.obj_type_ref() = PointFeature_symid;
push_stack(result);
}
else
***************
*** 599,628 ****
for (int i = 0; i < nf; i++) {
ComValue val(stack_arg(i));
if (val.type() == ComValue::ObjectType) {
! switch(val.obj_type_val()) {
! case POINT_FEATURE:
ptcount++;
! break;
! case LINE_FEATURE: {
ComponentView* lview = (ComponentView*)val.obj_val();
MapFeatureComp* lcomp = (MapFeatureComp*)lview->GetSubject();
MapFeature* lf = lcomp->feature();
MapEdge* le = lf->edge_primitive();
ptcount += le->topo()->npts();
! }
! break;
! case AREA_FEATURE: {
ComponentView* aview = (ComponentView*)val.obj_val();
MapFeatureComp* acomp = (MapFeatureComp*)aview->GetSubject();
MapFeature* af = acomp->feature();
MapFace* face = af->face_primitive();
ptcount += face->topo()->npts();
! }
! break;
! case NODE_FEATURE:
ptcount++;
! break;
! case FEATURE_CLASS: {
ComponentView* fcview = (ComponentView*)val.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
--- 608,630 ----
for (int i = 0; i < nf; i++) {
ComValue val(stack_arg(i));
if (val.type() == ComValue::ObjectType) {
! if (val.is_object(PointFeature_symid)) {
ptcount++;
! } else if (val.is_object(LineFeature_symid)) {
ComponentView* lview = (ComponentView*)val.obj_val();
MapFeatureComp* lcomp = (MapFeatureComp*)lview->GetSubject();
MapFeature* lf = lcomp->feature();
MapEdge* le = lf->edge_primitive();
ptcount += le->topo()->npts();
! } else if (val.is_object(AreaFeature_symid)) {
ComponentView* aview = (ComponentView*)val.obj_val();
MapFeatureComp* acomp = (MapFeatureComp*)aview->GetSubject();
MapFeature* af = acomp->feature();
MapFace* face = af->face_primitive();
ptcount += face->topo()->npts();
! } else if (val.is_object(NodeFeature_symid)) {
ptcount++;
! } else if (val.is_object(FeatureClass_symid)) {
ComponentView* fcview = (ComponentView*)val.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
***************
*** 644,651 ****
}
}
}
- break;
- }
}
}
float* fx = new float[ptcount];
--- 646,651 ----
***************
*** 654,661 ****
for (int i = 0; i < nf; i++) {
ComValue val(stack_arg(i));
if (val.type() == ComValue::ObjectType) {
! switch(val.obj_type_val()) {
! case POINT_FEATURE: {
ComponentView* pview = (ComponentView*)val.obj_val();
MapFeatureComp* pcomp = (MapFeatureComp*)pview->GetSubject();
MapFeature* pf = pcomp->feature();
--- 654,660 ----
for (int i = 0; i < nf; i++) {
ComValue val(stack_arg(i));
if (val.type() == ComValue::ObjectType) {
! if(val.is_object(PointFeature_symid)) {
ComponentView* pview = (ComponentView*)val.obj_val();
MapFeatureComp* pcomp = (MapFeatureComp*)pview->GetSubject();
MapFeature* pf = pcomp->feature();
***************
*** 663,671 ****
fx[pti] = pp->topo()->xpoints()[0];
fy[pti] = pp->topo()->ypoints()[0];
pti++;
! }
! break;
! case LINE_FEATURE: {
ComponentView* lview = (ComponentView*)val.obj_val();
MapFeatureComp* lcomp = (MapFeatureComp*)lview->GetSubject();
MapFeature* lf = lcomp->feature();
--- 662,668 ----
fx[pti] = pp->topo()->xpoints()[0];
fy[pti] = pp->topo()->ypoints()[0];
pti++;
! } else if (val.is_object(LineFeature_symid)) {
ComponentView* lview = (ComponentView*)val.obj_val();
MapFeatureComp* lcomp = (MapFeatureComp*)lview->GetSubject();
MapFeature* lf = lcomp->feature();
***************
*** 675,683 ****
fy[pti] = le->topo()->ypoints()[k];
pti++;
}
! }
! break;
! case AREA_FEATURE: {
ComponentView* aview = (ComponentView*)val.obj_val();
MapFeatureComp* acomp = (MapFeatureComp*)aview->GetSubject();
MapFeature* af = acomp->feature();
--- 672,678 ----
fy[pti] = le->topo()->ypoints()[k];
pti++;
}
! } else if (val.is_object(AreaFeature_symid)) {
ComponentView* aview = (ComponentView*)val.obj_val();
MapFeatureComp* acomp = (MapFeatureComp*)aview->GetSubject();
MapFeature* af = acomp->feature();
***************
*** 687,695 ****
fy[pti] = face->topo()->ypoints()[k];
pti++;
}
! }
! break;
! case NODE_FEATURE: {
ComponentView* nview = (ComponentView*)val.obj_val();
MapFeatureComp* ncomp = (MapFeatureComp*)nview->GetSubject();
MapFeature* nf = ncomp->feature();
--- 682,688 ----
fy[pti] = face->topo()->ypoints()[k];
pti++;
}
! } else if (val.is_object(NodeFeature_symid)) {
ComponentView* nview = (ComponentView*)val.obj_val();
MapFeatureComp* ncomp = (MapFeatureComp*)nview->GetSubject();
MapFeature* nf = ncomp->feature();
***************
*** 697,705 ****
fx[pti] = np->topo()->xpoints()[0];
fy[pti] = np->topo()->ypoints()[0];
pti++;
! }
! break;
! case FEATURE_CLASS: {
ComponentView* fcview = (ComponentView*)val.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
--- 690,696 ----
fx[pti] = np->topo()->xpoints()[0];
fy[pti] = np->topo()->ypoints()[0];
pti++;
! } else if (val.is_object(FeatureClass_symid)) {
ComponentView* fcview = (ComponentView*)val.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
***************
*** 733,740 ****
}
}
}
- break;
- }
}
}
reset_stack();
--- 724,729 ----
***************
*** 754,760 ****
ComponentView* hview = new ComponentView(hcomp);
ComValue result;
result.type(ComValue::ObjectType);
! result.obj_type_ref() = AREA_FEATURE;
result.obj_ref() = hview;
push_stack(result);
}
--- 743,749 ----
ComponentView* hview = new ComponentView(hcomp);
ComValue result;
result.type(ComValue::ObjectType);
! result.obj_type_ref() = AreaFeature_symid;
result.obj_ref() = hview;
push_stack(result);
}
***************
*** 887,895 ****
ComValue mf(stack_arg(1));
reset_stack();
if (mfc.type() == ComValue::ObjectType &&
! mfc.obj_type_val() == FEATURE_CLASS &&
mf.type() == ComValue::ObjectType &&
! mf.obj_type_val() == AREA_FEATURE) {
ComponentView* fcview = (ComponentView*)mfc.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
--- 876,884 ----
ComValue mf(stack_arg(1));
reset_stack();
if (mfc.type() == ComValue::ObjectType &&
! mfc.obj_type_val() == FeatureClass_symid &&
mf.type() == ComValue::ObjectType &&
! mf.obj_type_val() == AreaFeature_symid) {
ComponentView* fcview = (ComponentView*)mfc.obj_val();
MapFClassComp* fccomp = (MapFClassComp*)fcview->GetSubject();
MapFeatureClass* fc = fccomp->GetFeatureClass();
***************
*** 1083,1089 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 1072,1078 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 1304,1310 ****
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 1293,1299 ----
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 1482,1488 ****
result.type(AttributeValue::ObjectType);
result.obj_ref() = nfcview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 1471,1477 ----
result.type(AttributeValue::ObjectType);
result.obj_ref() = nfcview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
***************
*** 1505,1522 ****
ComValue nen(stack_key(_nen_symid));
reset_stack();
! ComponentView* view = (ComponentView*)fcc.obj_val();
! MapFClassComp* comp = (MapFClassComp*)view->GetSubject();
! MapFeatureClass* fc = comp->GetFeatureClass();
! double x1, y1, x2, y2;
! int zone;
! fc->extent(x1, y1, x2, y2, zone);
! if (zone==0) {
! char lon0[80];
! sprintf(lon0, "lon_0=%f", x1); // let proj pick the utm zone
! char* parms[4];
! parms[0] = "proj=utm";
! parms[1] = "ellps=WGS84";
parms[2] = lon0;
parms[3] = "no_defs";
PJ* proj = pj_init(4, parms);
--- 1494,1512 ----
ComValue nen(stack_key(_nen_symid));
reset_stack();
! ComponentView* view = (ComponentView*)fcc.geta(ComponentView_symid);
! MapFClassComp* comp = view ? (MapFClassComp*)view->GetSubject() : nil;
! MapFeatureClass* fc = comp ? comp->GetFeatureClass() : nil;
! if (fc) {
! double x1, y1, x2, y2;
! int zone;
! fc->extent(x1, y1, x2, y2, zone);
! if (zone==0) {
! char lon0[80];
! sprintf(lon0, "lon_0=%f", x1); // let proj pick the utm zone
! char* parms[4];
! parms[0] = "proj=utm";
! parms[1] = "ellps=WGS84";
parms[2] = lon0;
parms[3] = "no_defs";
PJ* proj = pj_init(4, parms);
***************
*** 1531,1558 ****
data = pj_fwd(data, proj);
x2 = data.u;
y2 = data.v;
! }
#if 0
! cout << "(" << Math::round(x1) << ", " << Math::round(y1)
! << ", " << Math::round(x2) << ", " << Math::round(y2) << ")\n";
#endif
! int nflags = swn.is_true() + swe.is_true() + nen.is_true() + nee.is_true();
! if (nflags==0 || nflags>1) {
! AttributeValueList* al = new AttributeValueList();
! if (swe.is_true() || !nflags) al->Append(new AttributeValue(x1));
! if (swn.is_true() || !nflags) al->Append(new AttributeValue(y1));
! if (nee.is_true() || !nflags) al->Append(new AttributeValue(x2));
! if (nen.is_true() || !nflags) al->Append(new AttributeValue(y2));
! ComValue retval(al);
! push_stack(retval);
! } else {
! double result;
! if (swe.is_true()) result = x1;
! if (swn.is_true()) result = y1;
! if (nee.is_true()) result = x2;
! if (nen.is_true()) result = y2;
! ComValue retval(result);
! push_stack(retval);
}
}
--- 1521,1549 ----
data = pj_fwd(data, proj);
x2 = data.u;
y2 = data.v;
! }
#if 0
! cout << "(" << Math::round(x1) << ", " << Math::round(y1)
! << ", " << Math::round(x2) << ", " << Math::round(y2) << ")\n";
#endif
! int nflags = swn.is_true() + swe.is_true() + nen.is_true() + nee.is_true();
! if (nflags==0 || nflags>1) {
! AttributeValueList* al = new AttributeValueList();
! if (swe.is_true() || !nflags) al->Append(new AttributeValue(x1));
! if (swn.is_true() || !nflags) al->Append(new AttributeValue(y1));
! if (nee.is_true() || !nflags) al->Append(new AttributeValue(x2));
! if (nen.is_true() || !nflags) al->Append(new AttributeValue(y2));
! ComValue retval(al);
! push_stack(retval);
! } else {
! double result;
! if (swe.is_true()) result = x1;
! if (swn.is_true()) result = y1;
! if (nee.is_true()) result = x2;
! if (nen.is_true()) result = y2;
! ComValue retval(result);
! push_stack(retval);
! }
}
}
***************
*** 1602,1608 ****
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
delete attrterp;
--- 1593,1599 ----
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
delete attrterp;
***************
*** 1701,1707 ****
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
delete attrterp;
--- 1692,1698 ----
result.type(AttributeValue::ObjectType);
result.obj_ref() = nview;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
delete attrterp;
***************
*** 2304,2310 ****
if (comp && comp->IsA(MAPFCLASS_COMP)) {
ComponentView* view = new ComponentView(comp);
ComValue result(ComValue::ObjectType, (void*)view);
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
} else {
if (comp) delete comp;
--- 2295,2301 ----
if (comp && comp->IsA(MAPFCLASS_COMP)) {
ComponentView* view = new ComponentView(comp);
ComValue result(ComValue::ObjectType, (void*)view);
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
} else {
if (comp) delete comp;
***************
*** 2321,2327 ****
ComValue fclass(stack_arg(0));
reset_stack();
if (fclass.type() == ComValue::ObjectType &&
! fclass.obj_type_val() == FEATURE_CLASS) {
ComponentView* view = (ComponentView*)fclass.obj_val();
MapFClassComp* comp = (MapFClassComp*)view->GetSubject();
MapFeatureClass* fc = comp->GetFeatureClass();
--- 2312,2318 ----
ComValue fclass(stack_arg(0));
reset_stack();
if (fclass.type() == ComValue::ObjectType &&
! fclass.obj_type_val() == FeatureClass_symid) {
ComponentView* view = (ComponentView*)fclass.obj_val();
MapFClassComp* comp = (MapFClassComp*)view->GetSubject();
MapFeatureClass* fc = comp->GetFeatureClass();
***************
*** 2342,2348 ****
ComValue fn(stack_arg(1));
reset_stack();
if (fclass.type() == ComValue::ObjectType &&
! fclass.obj_type_val() == FEATURE_CLASS &&
fn.type() == ComValue::IntType) {
ComponentView* view = (ComponentView*)fclass.obj_val();
MapFClassComp* comp = (MapFClassComp*)view->GetSubject();
--- 2333,2339 ----
ComValue fn(stack_arg(1));
reset_stack();
if (fclass.type() == ComValue::ObjectType &&
! fclass.obj_type_val() == FeatureClass_symid &&
fn.type() == ComValue::IntType) {
ComponentView* view = (ComponentView*)fclass.obj_val();
MapFClassComp* comp = (MapFClassComp*)view->GetSubject();
***************
*** 2356,2374 ****
result.type(ComValue::ObjectType);
switch(feature->type()) {
case MapFeature::PointType:
! result.obj_type_ref() = POINT_FEATURE;
newf = copy_point(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::LineType:
! result.obj_type_ref() = LINE_FEATURE;
newf = copy_line(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::AreaType:
! result.obj_type_ref() = AREA_FEATURE;
newf = copy_area(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::JunctionType:
! result.obj_type_ref() = NODE_FEATURE;
newf = copy_junction(feature, (MapFeatureComp*)feature->graphic());
break;
}
--- 2347,2365 ----
result.type(ComValue::ObjectType);
switch(feature->type()) {
case MapFeature::PointType:
! result.obj_type_ref() = PointFeature_symid;
newf = copy_point(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::LineType:
! result.obj_type_ref() = LineFeature_symid;
newf = copy_line(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::AreaType:
! result.obj_type_ref() = AreaFeature_symid;
newf = copy_area(feature, (MapFeatureComp*)feature->graphic());
break;
case MapFeature::JunctionType:
! result.obj_type_ref() = NodeFeature_symid;
newf = copy_junction(feature, (MapFeatureComp*)feature->graphic());
break;
}
Index: LosServ/losfunc.c
diff -c LosServ/losfunc.c:1.3 LosServ/losfunc.c:1.4
*** LosServ/losfunc.c:1.3 Tue Jan 25 03:22:07 2000
--- src/LosServ/losfunc.c Tue Mar 14 22:52:11 2000
***************
*** 74,79 ****
--- 74,82 ----
//int round(double x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); }
UsgsDem* dem;
+ #include <ComUtil/comutil.h>
+ static int FeatureClass_symid = symbol_add("FeatureClass");
+
/*****************************************************************************/
DemLosFunc::DemLosFunc(ComTerp* comterp) : ComFunc(comterp) {
***************
*** 226,232 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
else {
--- 229,235 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
else {
***************
*** 424,430 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
}
--- 427,433 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
}
***************
*** 670,676 ****
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
}
--- 673,679 ----
ComValue result;
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FeatureClass_symid;
push_stack(result);
}
}
Index: ProjServ/projfunc.c
diff -c ProjServ/projfunc.c:1.1 ProjServ/projfunc.c:1.2
*** ProjServ/projfunc.c:1.1 Mon Aug 2 13:53:39 1999
--- src/ProjServ/projfunc.c Tue Mar 14 22:52:13 2000
***************
*** 63,68 ****
--- 63,71 ----
#include <strstream.h>
#include <stdio.h>
+ #include <ComUtil/comutil.h>
+ static int ComponentView_symid = symbol_add("ComponentView");
+
LoadVpfFCFunc::LoadVpfFCFunc(ComTerp* comterp) : ComFunc(comterp) {
_tileid_symid = symbol_add("tileid");
}
***************
*** 82,122 ****
Creator::instance(new VpfCreator());
const char* dbdir = dbpath.string_ptr();
VpfDatabase* db = new VpfDatabase(dbdir);
! VpfLibrary* lib = db->library(libname.string_ptr());
! VpfDbComp* dbcomp = new VpfDbComp(db);
! MapShowCmd* showcmd = new MapShowCmd();
! showcmd->SetUseEditor(false);
! showcmd->SetLibName(libname.string_ptr());
! showcmd->SetCovName(covname.string_ptr());
! showcmd->SetFClassName(fcname.string_ptr());
! VpfExtent* ext = lib->extent();
! if (utmflag.is_true()) {
! char lon0[80];
! sprintf(lon0, "lon_0=%f", ext->x1); // let proj pick the utm zone
! char* parms[4];
! parms[0] = "proj=utm";
! parms[1] = "ellps=WGS84";
! parms[2] = lon0;
! parms[3] = "no_defs";
! PJ* proj = pj_init(4, parms);
! showcmd->SetProjection(proj);
}
! if (tileid.type() != ComValue::UnknownType) {
! int tid = tileid.int_val();
! showcmd->SetTileId(tid);
}
- dbcomp->Interpret(showcmd);
-
- VpfLibComp* libcomp = (VpfLibComp*)dbcomp->FindLibComp(lib);
- VpfCoverage* cov = lib->coverage(covname.string_ptr());
- VpfCovComp* covcomp = (VpfCovComp*)libcomp->FindCovComp(cov);
- VpfFeatureClass* fclass = cov->feature_class(fcname.string_ptr());
- VpfFClassComp* fccomp = (VpfFClassComp*)covcomp->FindFClassComp(fclass);
- ComponentView* view = new ComponentView(fccomp);
- result.type(AttributeValue::ObjectType);
- result.obj_ref() = view;
- result.obj_type_ref() = FEATURE_CLASS;
- push_stack(result);
}
VpfTileIdsByGeoFunc::VpfTileIdsByGeoFunc(ComTerp* comterp) : ComFunc(comterp) {
--- 85,144 ----
Creator::instance(new VpfCreator());
const char* dbdir = dbpath.string_ptr();
VpfDatabase* db = new VpfDatabase(dbdir);
! VpfLibrary* lib = db->valid() ? db->library(libname.string_ptr()) : nil;
! VpfDbComp* dbcomp = db->valid() ? new VpfDbComp(db) : nil;
! if (dbcomp) {
! MapShowCmd* showcmd = new MapShowCmd();
! showcmd->SetUseEditor(false);
! showcmd->SetLibName(libname.string_ptr());
! showcmd->SetCovName(covname.string_ptr());
! showcmd->SetFClassName(fcname.string_ptr());
! VpfExtent* ext = lib->extent();
! if (utmflag.is_true()) {
! char lon0[80];
! sprintf(lon0, "lon_0=%f", ext->x1); // let proj pick the utm zone
! char* parms[4];
! parms[0] = "proj=utm";
! parms[1] = "ellps=WGS84";
! parms[2] = lon0;
! parms[3] = "no_defs";
! PJ* proj = pj_init(4, parms);
! showcmd->SetProjection(proj);
! }
! if (tileid.type() != ComValue::UnknownType) {
! int tid = tileid.int_val();
! showcmd->SetTileId(tid);
! }
! dbcomp->Interpret(showcmd);
!
! VpfLibComp* libcomp = (VpfLibComp*)dbcomp->FindLibComp(lib);
! VpfCoverage* cov = lib->coverage(covname.string_ptr());
! VpfCovComp* covcomp = (VpfCovComp*)libcomp->FindCovComp(cov);
! VpfFeatureClass* fclass = cov->feature_class(fcname.string_ptr());
! VpfFClassComp* fccomp = (VpfFClassComp*)covcomp->FindFClassComp(fclass);
! ComponentView* view = fccomp ? new ComponentView(fccomp) : nil;
! if (view) {
! result.type(AttributeValue::ObjectType);
! result.obj_ref() = view;
! result.obj_type_ref() = ComponentView_symid;
! push_stack(result);
! } else {
! cerr << "database open failed\n";
! delete db;
! delete lib;
! delete libcomp;
! delete cov;
! delete covcomp;
! delete fclass;
! delete fccomp;
! push_stack(ComValue::nullval());
! }
}
! else {
! cerr << "database open failed\n";
! delete db;
! push_stack(ComValue::nullval());
}
}
VpfTileIdsByGeoFunc::VpfTileIdsByGeoFunc(ComTerp* comterp) : ComFunc(comterp) {
***************
*** 194,200 ****
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 216,222 ----
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = ComponentView_symid;
push_stack(result);
}
***************
*** 284,289 ****
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = FEATURE_CLASS;
push_stack(result);
}
--- 306,311 ----
ComponentView* view = new ComponentView(fccomp);
result.type(AttributeValue::ObjectType);
result.obj_ref() = view;
! result.obj_type_ref() = ComponentView_symid;
push_stack(result);
}
*** /dev/null Tue Mar 14 22:52:21 PST 2000
--- patches/vhclmaps-000314-johnston-012
*************** patches/vhclmaps-000314-johnston-012
*** 0 ****
--- 1 ----
+ vhclmaps-000314-johnston-012
|