示例#1
0
文件: Xlist.cpp 项目: F5000/spree
BOOL _XList::movePosition( _XItem* curPosItem, int newPosition )
{
	if( !curPosItem || newPosition > this->itemcount-1 ) return FALSE;
	
	// 옮기려는 스프라이트가 조상(리스트의 헤더)일때 조상 재설정
	
	if( firstItem()==curPosItem )
	{
		if( newPosition == 0 ) return FALSE;
		setAnchor( curPosItem->getright() );
		curPosItem->unlink();
		resetList();
		for(int i=0; i < newPosition; i++) nextItem();
		insertItem( curPosItem );
		return TRUE;
	}
	
	if( newPosition > 0 )
	{
		curPosItem->unlink();
		resetList();
		for(int i=0; i < newPosition; i++) nextItem();
		insertItem( curPosItem );
	}
	else // 리스트의 헤더로 옮기고자 할때 헤더 재설정 
	{
		curPosItem->unlink();
		resetList();
		insertItem( curPosItem );
		setAnchor( curPosItem );

	}
	return TRUE;
}
示例#2
0
文件: Xlist.cpp 项目: F5000/spree
BOOL _XList::movePosition( int curPosition, int newPosition )
{	
	if( curPosition == newPosition ) return FALSE;	
	
	_XItem* curItem = getItem( curPosition );

	if( !curItem ) return FALSE;
	
	if( firstItem()==curItem )
	{
		if( newPosition == 0 ) return FALSE;
		removeItem( curItem );		
		resetList();
		for(int i=0; i < newPosition; i++) nextItem();
		insertItem( curItem );
		return TRUE;
	}
	
	if( newPosition > 0 )
	{
		removeItem( curItem );
		resetList();
		for(int i=0; i < newPosition; i++) nextItem();
		insertItem( curItem );
	}
	else // 리스트의 헤더로 옮기고자 할때 헤더 재설정 
	{		
		removeItem( curItem );
		resetList();
		insertItem( curItem );
		setAnchor( curItem );
	}
	return TRUE;
}
示例#3
0
void radixSort(int *a, int n, int *endResult)
{
    comparisons = 0;
    assignments = 0;
    int i;
    /*DEBUG
    printf("Before\n");
    for(i = 0; i < n; i++)
        printf("%d ", a[i]);
    printf("\n");
    DEBUG*/
    List* lstv = (List*)malloc(sizeof(List) * 10);
    for(i = 0; i < 10; i++)
        initList(&lstv[i]);
    resetList(lstv);

    long int count = 1;
    int allZero = 0;
    while(allZero == 0)
    {
        allZero = 1;
        ///Sort them into the list vector
        for(i = 0; i < n; i++)
        {
            int digit = (a[i]/count) % 10;
            enq(&lstv[digit], a[i]);
            if(digit != 0)
                allZero = 0;
            assignments++;
        }
        ///Remake the vector
        int j = 0;
        for(i = 0; i < 10; i++)
        {
            while(lstv[i].head != NULL)
            {
                a[j++] = peekNodeData(&lstv[i]);
                deq(&lstv[i]);
                assignments++;
            }
        }

        count *= 10;
        resetList(lstv);
    }
    for(i = 0; i < n; i++)
        endResult[i] = a[i];
    /*DEBUG
    printf("After\n");
    for(i = 0; i < n; i++)
        printf("%d ", endResult[i]);
    printf("\n");
    DEBUG*/
}
void resetList(block & t, map<string,bool> & used)
{
	//-------- resets the log of what blocks have been used in the last print stage
	used[""]=false;
	used[t.title]=false;
	for (unsigned int i=0; i<t.numInside(); i++) {
		resetList(t.blocksIn[i],used);
	}
	for (unsigned int i=0; i<t.size(); i++) {
		resetList(t.blocksOn[i],used);
	}
}
示例#5
0
LRESULT COverlayPanel::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// Subclass the overlays combo box window
	overlaysCombo.SubclassWindow(GetDlgItem(IDC_COMBO_OVERLAY), IDC_COMBO_OVERLAY);

	// Sort out the overlay drop down list
	char **keys = (char**) malloc(sizeof(const char*) * COverlayFactory::typeCount());
	COverlayFactory::listTypes(keys);

	for (int i=0; i<COverlayFactory::typeCount(); i++)
	{
		SendDlgItemMessage(IDC_OVERLAY_TYPE,CB_ADDSTRING,0,(LPARAM)keys[i]);
	}

	SendDlgItemMessage(IDC_OVERLAY_TYPE,CB_SETCURSEL,0,0);

	free(keys);

	// Draw the tree of overlays.
	resetList();

	// Draw the tree of effect overlays
	resetOverlayList();

	return TRUE;
}
示例#6
0
ListHolder::~ListHolder()
{
	resetList();
// 	for (ListItemStore::iterator I(mItems.begin()); I != mItems.end(); ++I) {
// 		delete *I;
// 	}
}
LIST_HEAD *createList(void) {
    LIST_HEAD *newList = (LIST_HEAD *) malloc(sizeof (LIST_HEAD));
    if (newList == NULL) {
        return NULL;
    }
    resetList(newList);
    return newList;
}
void AssetTypeDialog::newType()
{
	EditAssetTypeDialog * eat = new EditAssetTypeDialog( this );
	if( eat->exec() == QDialog::Accepted ) {
		AssetType at = eat->assetType();
		at.commit();
		mAssetTypes += at;
		resetList();
	}
	delete eat;
}
void emptyList(LIST_HEAD *list) {
    NODE *del = list->head;
    if (del == NULL) {
        return;
    }
    while (del->next != NULL) {
        removeNode(list, del->next);
    }
    free(del);
    resetList(list);
}
示例#10
0
int COverlayPanel::duplicate(ICompositeOverlay *root, IOverlay *item)
{
	IOverlay *o;
	item->clone(&o);
	root->Add(o);
	o->Release();

	resetList(o);
	enable(o);

	return TRUE;
}
示例#11
0
int COverlayPanel::add(ICompositeOverlay *root, const char *overlayType)
{	
	IOverlay *o = COverlayFactory::createInstance(overlayType, model);
	o->put_Name(_bstr_t("New Overlay"));
	root->Add(o);
	o->Release();

	resetList(o);
	enable(o);

	return TRUE;
}
void AssetTypeDialog::editType()
{
	EditAssetTypeDialog * eat = new EditAssetTypeDialog( this );
	eat->setAssetType( mCurrentType );
	if( eat->exec() == QDialog::Accepted ) {
		if( mCurrentType.isTask() != eat->assetType().isTask() )
			Element::invalidatePathCache();
		eat->assetType().commit();
	}
	resetList();
	delete eat;
}
示例#13
0
void 
GlutMenu::reset()
{
	if (_menuID!=-1)
	{
		glutSetMenu(_menuID);
		int n = glutGet(GLenum(GLUT_MENU_NUM_ITEMS));
		for (int i=0; i<n; i++)
			glutRemoveMenuItem(1);
	}

	resetList();
}
AssetTypeDialog::AssetTypeDialog( QWidget * parent )
: QDialog( parent )
{
	setupUi( this );
	mAssetTypes = AssetType::select().sorted( "name" );
	resetList();
	connect( mNewType, SIGNAL( clicked() ), SLOT( newType() ) );
	connect( mRemoveType, SIGNAL( clicked() ), SLOT( toggleTypeDisabled() ) );
	connect( mEditType, SIGNAL( clicked() ), SLOT( editType() ) );

	connect( mShowDisabled, SIGNAL( toggled( bool ) ), SLOT( showDisabled( bool ) ) );
	connect( mTypeList, SIGNAL( currentTextChanged( const QString & ) ), SLOT( currentTypeChanged( const QString & ) ) );
	currentTypeChanged("");
}
示例#15
0
int COverlayPanel::remove(ICompositeOverlay *root, IOverlay *item)
{
	short i;
	root->GetIndex(item, &i);
	root->Remove(CComVariant(i));

	root->Item(CComVariant(i), &item);

	resetList(item);

	enable(item);

	if (item)
		item->Release();

	return TRUE;
}
示例#16
0
文件: Xlist.cpp 项目: F5000/spree
int _XList::searchItem( _XItem* ip )
{
	 BOOL i=0,Find = FALSE;
	 resetList();
	 do
	 {	 
		 if( ip == cip )
		 {
			 Find = TRUE;
		     break;
		 }
		 i++;
		 nextItem();
	 } while( !atHeadOfList() );

	 if( Find ) return i;
	 else return -1;
}
示例#17
0
int COverlayPanel::rename(IOverlay *pOverlay)
{
	char buf[64];
	BSTR name;
	pOverlay->get_Name(&name);
	strcpy(buf, (char*)_bstr_t(name, false));
	CRenameDialog *d = new CRenameDialog(buf);
	d->DoModal(m_hWnd);
	delete d;

	if (*buf != 0)	// Can't have empty strings
	{
		pOverlay->put_Name(_bstr_t(buf));
		resetList(pOverlay);
	}

	return FALSE;
}
示例#18
0
int COverlayPanel::down(ICompositeOverlay *superRoot, ICompositeOverlay *root, IOverlay *item)
{
	short i;
	root->GetIndex(item, &i);
	CComVariant index(i);
	short max;
	root->Count(&max);
	if (i != max-1)
	{
		// This is not the last item in the container
		IOverlay *next;
		root->Item(CComVariant(i+1), &next);
		ICompositeOverlay *pCO = NULL;
		HRESULT hr = next->QueryInterface(IID_ICompositeOverlay, (void **)&pCO);
		if (SUCCEEDED(hr))
		{
			// Next item IS composite - add to the end of THAT container.
			pCO->Release();
			//Add before remove.
			((ICompositeOverlay*)next)->AddAt(item, CComVariant(0));
			root->Remove(index);
		}
		else
		{
			// Next item is not composite. Just swap them.
			root->Swap(CComVariant(i+1), index);
		}
		next->Release();
	}
	else if (superRoot)
	{
		// This IS the last item in the container, Move into the container's
		// parent, if there is one, just after this container.

		// Add before remove.
		superRoot->GetIndex(root, &i);
		superRoot->AddAt(item, CComVariant(i+1));
		root->Remove(index);
	}

	resetList(item);

	return TRUE;
}
示例#19
0
MenuContext::MenuContext()
  : iKeyboardIncrement(1), cFocusParameter(INVALID_IDX), iStatus(0)
{

	for (uint8_t i=0; i < NUMBER_OF_TIMERS; i++) {
		periodTimers[i]=0;
	}

	for (uint8_t i=0; i < NUMBER_OF_PARAMETERS; i++) {

		iParamValue[i] = i;
		}

	iParamValue[11] = (18*3600UL + 59*60UL + 59UL);
	iParamValue[25] = 0;

    resetList();

}
示例#20
0
CountryList::CountryList(QWidget *parent, const style::countryList &st) : QWidget(parent), _sel(0),
	_st(st), _mouseSel(false) {
	CountriesByISO2::const_iterator l = countriesByISO2.constFind(lastValidISO);
	bool seenLastValid = false;
	int already = countriesAll.size();

	countriesByLetter.clear();
	const CountryInfo *lastValid = (l == countriesByISO2.cend()) ? 0 : (*l);
	for (int i = 0; i < countriesCount; ++i) {
		const CountryInfo *ins = lastValid ? (i ? (countries + i - (seenLastValid ? 0 : 1)) : lastValid) : (countries + i);
		if (lastValid && i && ins == lastValid) {
			seenLastValid = true;
			++ins;
		}
		if (already > i) {
			countriesAll[i] = ins;
		} else {
			countriesAll.push_back(ins);
		}
	
		QStringList namesList = QString::fromUtf8(ins->name).toLower().split(QRegularExpression("[\\s\\-]"), QString::SkipEmptyParts);
		CountryNames &names(countriesNames[i]);
		int l = namesList.size();
		names.resize(0);
		names.reserve(l);
		for (int j = 0, l = namesList.size(); j < l; ++j) {
			QString name = namesList[j].trimmed();
			if (!name.length()) continue;

			QChar ch = name[0];
			CountriesIds &v(countriesByLetter[ch]);
			if (v.isEmpty() || v.back() != i) {
				v.push_back(i);
			}

			names.push_back(name);
		}
	}

	lastFilter = "";
	resetList();
}
示例#21
0
/*----------------------------------------------------------------------------
  Main function
 *----------------------------------------------------------------------------*/
int main (void) {
	
	//SysTick_Config(SystemCoreClock/1000);      /* Generate interrupt each 100 ms  */

	//Initialize the required I/O device libraries
	JOY_Init();
	LED_Init();
	SER_Init();
	KBD_Init();
	SRAM_Init();
	GLCD_Init();     // LCD Initialization
	
	time.min = 0;
	time.hours = 12;
	time.sec = 0;
	
	USART3->CR1 |= (1<<5); //Enable the "data received" interrupt for USART3
	NVIC_EnableIRQ(USART3_IRQn); //Enable interrupts for USART3
	NVIC_SetPriority (USART3_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
	
	resetList();

  //memcpy(&tailMessage->text,"This is a test of some really random text that I'm sending as part of a text message. I hope it works! Let's keep typing just to see if we can fill up 160 chars",160);
	
	//Here we are manually setting the head node to display a "No Messages" message if we are not storing anything else
	memcpy(&headMessage->text,"No Messages",11);
	headMessage->length = 11;
	headMessage->prev = NULL;
	headMessage->next = NULL;
	headMessage->rxTime.hours = 0;
	headMessage->rxTime.min = 0;
	headMessage->rxTime.sec = 0;
	displayedMessage = headMessage;
	
	
	//Initialize the LCD
	
	init_display();
	
	os_sys_init_prio(initTask,0xFE);
  
}
示例#22
0
int COverlayPanel::up(ICompositeOverlay *superRoot, ICompositeOverlay *root, IOverlay *item)
{
	short i;
	root->GetIndex(item, &i);
	CComVariant index(i);
	if (i != 0)
	{
		// This is not the first item in the container
		IOverlay *prev;
		root->Item(CComVariant(i-1), &prev);
		ICompositeOverlay *pCO = NULL;
		HRESULT hr = prev->QueryInterface(IID_ICompositeOverlay, (void **)&pCO);
		if (SUCCEEDED(hr))
		{
			// Previous item IS composite - add to the end of THAT container.
			pCO->Release();
			// Add before remove - don't want to drop reference count to zero.
			((ICompositeOverlay*)prev)->Add(item);
			root->Remove(index);
		}
		else
		{
			// Previous item is not composite. Just swap them.
			root->Swap(CComVariant(i-1), index);
		}
		prev->Release();
	}
	else if (superRoot)
	{
		// This IS the first item in the container. Move into the container's
		// parent just before this container, if there is one.
		// Add before remove.
		superRoot->GetIndex(root, &i);
		superRoot->AddAt(item, CComVariant(i));
		root->Remove(index);
	}

	resetList(item);
	return TRUE;
}
示例#23
0
void EndElement(xmlTextReaderPtr reader, const xmlChar *name)
{
   unsigned int id;

   DEBUG("%s: %s\n", __FUNCTION__, name);

   if (xmlStrEqual(name, BAD_CAST "node")) {
      int i;
      char *values = NULL, *names = NULL;
      char *osm_id = getItem(&keys, "id");
      if (!osm_id) {
         fprintf(stderr, "%s: Node ID not in keys\n", __FUNCTION__);
         resetList(&keys);
         resetList(&tags);
         return;
      }
      id = strtoul(osm_id, NULL, 10);
      //assert(nodes[id].lat && nodes[id].lon);
      for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++) {
         char *v;
         if ((v = getItem(&tags, exportTags[i].name))) {
            if (values) {
               char *oldval = values, *oldnam = names;
               asprintf(&names,  "%s,\"%s\"", oldnam, exportTags[i].name);
               asprintf(&values, "%s,$$%s$$", oldval, v);
               free(oldnam);
               free(oldval);
            } else {
               asprintf(&names,  "\"%s\"", exportTags[i].name);
               asprintf(&values, "$$%s$$", v);
            }
         }
      }
      if (values) {
         count_node++;
         printf("insert into %s (osm_id,%s,way) values "
		"(%s,%s,GeomFromText('POINT(%.15g %.15g)',4326));\n", 
		table_name_point,names,osm_id,values,nodes[id].lon, nodes[id].lat);
      }
      resetList(&keys);
      resetList(&tags);
      free(values);
      free(names);
   } else if (xmlStrEqual(name, BAD_CAST "segment")) {
      resetList(&tags);
   } else if (xmlStrEqual(name, BAD_CAST "tag")) {
      /* Separate tag list so tag stack unused */
   } else if (xmlStrEqual(name, BAD_CAST "way")) {
      int i, polygon = 0; 
      char *values = NULL, *names = NULL;
      char *osm_id = getItem(&keys, "id");

      if (!osm_id) {
         fprintf(stderr, "%s: WAY ID not in keys\n", __FUNCTION__);
         resetList(&keys);
         resetList(&tags);
         resetList(&segs);
         return;
      }

      if (!listHasData(&segs)) {
         DEBUG("%s: WAY(%s) has no segments\n", __FUNCTION__, osm_id);
         resetList(&keys);
         resetList(&tags);
         resetList(&segs);
         return;
      }
      id  = strtoul(osm_id, NULL, 10);

      for (i=0; i < sizeof(exportTags) / sizeof(exportTags[0]); i++) {
         char *v;
         if ((v = getItem(&tags, exportTags[i].name))) {
            if (values) {
               char *oldval = values, *oldnam = names;
               asprintf(&names,  "%s,\"%s\"", oldnam, exportTags[i].name);
               asprintf(&values, "%s,$$%s$$", oldval, v);
               free(oldnam);
               free(oldval);
            } else {
               asprintf(&names,  "\"%s\"", exportTags[i].name);
               asprintf(&values, "$$%s$$", v);
            }
            polygon |= exportTags[i].polygon;
         }
      }
      if (values) {
         size_t wkt_size = WKT(polygon);

         if (wkt_size)
         {
            unsigned i;
            for (i=0;i<wkt_size;i++)
            {
               const char * wkt = get_wkt(i);
               if (strlen(wkt)) {
		 if (polygon) {
                     printf("insert into %s (osm_id,%s,way) values (%s,%s,GeomFromText('%s',4326));\n", table_name_polygon,names,osm_id,values,wkt);
		 }
		 else {
		   printf("insert into %s (osm_id,%s,way) values (%s,%s,GeomFromText('%s',4326));\n", table_name_line,names,osm_id,values,wkt);
		 }
		 count_way++;	
               }
            }
            clear_wkts();
         }
      }

      resetList(&keys);
      resetList(&tags);
      resetList(&segs);
      free(values);
      free(names);
   } else if (xmlStrEqual(name, BAD_CAST "seg")) {
      /* ignore */
   } else if (xmlStrEqual(name, BAD_CAST "osm")) {
      /* ignore */
   } else {
      fprintf(stderr, "%s: Unknown element name: %s\n", __FUNCTION__, name);
   }
}
示例#24
0
文件: Xlist.cpp 项目: F5000/spree
_XItem *_XList::getItem( int Pos )
{
	 resetList();
	 for( int i=0; i<Pos; i++ ) nextItem();
	 return cip;
}
示例#25
0
static unsigned int tagtransform_c_filter_rel_member_tags(
        struct keyval *rel_tags, int member_count,
        struct keyval *member_tags, const char **member_role,
        int * member_superseeded, int * make_boundary, int * make_polygon, int * roads) {
    char *type;
    struct keyval tags, *p, poly_tags;
    int i;

    /* Get the type, if there's no type we don't care */
    type = getItem(rel_tags, "type");
    if (!type)
        return 1;

    initList(&tags);
    initList(&poly_tags);

    /* Clone tags from relation */
    p = rel_tags->next;
    while (p != rel_tags) {
        /* For routes, we convert name to route_name */
        if ((strcmp(type, "route") == 0) && (strcmp(p->key, "name") == 0))
            addItem(&tags, "route_name", p->value, 1);
        else if (strcmp(p->key, "type")) /* drop type= */
            addItem(&tags, p->key, p->value, 1);
        p = p->next;
    }

    if (strcmp(type, "route") == 0) {
        const char *state = getItem(rel_tags, "state");
        const char *netw = getItem(rel_tags, "network");
        int networknr = -1;

        if (state == NULL ) {
            state = "";
        }

        if (netw != NULL ) {
            if (strcmp(netw, "lcn") == 0) {
                networknr = 10;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "lcn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "lcn", "connection", 1);
                } else {
                    addItem(&tags, "lcn", "yes", 1);
                }
            } else if (strcmp(netw, "rcn") == 0) {
                networknr = 11;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "rcn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "rcn", "connection", 1);
                } else {
                    addItem(&tags, "rcn", "yes", 1);
                }
            } else if (strcmp(netw, "ncn") == 0) {
                networknr = 12;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "ncn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "ncn", "connection", 1);
                } else {
                    addItem(&tags, "ncn", "yes", 1);
                }

            } else if (strcmp(netw, "lwn") == 0) {
                networknr = 20;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "lwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "lwn", "connection", 1);
                } else {
                    addItem(&tags, "lwn", "yes", 1);
                }
            } else if (strcmp(netw, "rwn") == 0) {
                networknr = 21;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "rwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "rwn", "connection", 1);
                } else {
                    addItem(&tags, "rwn", "yes", 1);
                }
            } else if (strcmp(netw, "nwn") == 0) {
                networknr = 22;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "nwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "nwn", "connection", 1);
                } else {
                    addItem(&tags, "nwn", "yes", 1);
                }
            }
        }

        if (getItem(rel_tags, "preferred_color") != NULL ) {
            const char *a = getItem(rel_tags, "preferred_color");
            if (strcmp(a, "0") == 0 || strcmp(a, "1") == 0
                    || strcmp(a, "2") == 0 || strcmp(a, "3") == 0
                    || strcmp(a, "4") == 0) {
                addItem(&tags, "route_pref_color", a, 1);
            } else {
                addItem(&tags, "route_pref_color", "0", 1);
            }
        } else {
            addItem(&tags, "route_pref_color", "0", 1);
        }

        if (getItem(rel_tags, "ref") != NULL ) {
            if (networknr == 10) {
                addItem(&tags, "lcn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 11) {
                addItem(&tags, "rcn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 12) {
                addItem(&tags, "ncn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 20) {
                addItem(&tags, "lwn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 21) {
                addItem(&tags, "rwn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 22) {
                addItem(&tags, "nwn_ref", getItem(rel_tags, "ref"), 1);
            }
        }
    } else if (strcmp(type, "boundary") == 0) {
        /* Boundaries will get converted into multiple geometries:
         - Linear features will end up in the line and roads tables (useful for admin boundaries)
         - Polygon features also go into the polygon table (useful for national_forests)
         The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
        *make_boundary = 1;
    } else if (strcmp(type, "multipolygon") == 0
            && getItem(&tags, "boundary")) {
        /* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
        *make_boundary = 1;
    } else if (strcmp(type, "multipolygon") == 0) {
        *make_polygon = 1;

        /* Copy the tags from the outer way(s) if the relation is untagged */
        /* or if there is just a name tag, people seem to like naming relations */
        if (!listHasData(&tags)
                || ((countList(&tags) == 1) && getItem(&tags, "name"))) {
            for (i = 0; i < member_count; i++) {
                if (member_role[i] && !strcmp(member_role[i], "inner"))
                    continue;

                p = member_tags[i].next;
                while (p != &(member_tags[i])) {
                    addItem(&tags, p->key, p->value, 1);
                    p = p->next;
                }
            }
        }

        /* Collect a list of polygon-like tags, these are used later to
         identify if an inner rings looks like it should be rendered separately */
        p = tags.next;
        while (p != &tags) {
            if (!strcmp(p->key, "area")) {
                addItem(&poly_tags, p->key, p->value, 1);
            } else {
                for (i = 0; i < exportListCount[OSMTYPE_WAY]; i++) {
                    if (strcmp(exportList[OSMTYPE_WAY][i].name, p->key) == 0) {
                        if (exportList[OSMTYPE_WAY][i].flags & FLAG_POLYGON) {
                            addItem(&poly_tags, p->key, p->value, 1);
                        }
                        break;
                    }
                }
            }
            p = p->next;
        }
    } else {
        /* Unknown type, just exit */
        resetList(&tags);
        resetList(&poly_tags);
        return 1;
    }

    /* If we are creating a multipolygon then we
     mark each member so that we can skip them during iterate_ways
     but only if the polygon-tags look the same as the outer ring */
    if (make_polygon) {
        for (i = 0; i < member_count; i++) {
            int match = 0;
            struct keyval *p = poly_tags.next;
            while (p != &poly_tags) {
                const char *v = getItem(&(member_tags[i]), p->key);
                if (!v || strcmp(v, p->value)) {
                    match = 0;
                    break;
                }
                match = 1;
                p = p->next;
            }
            if (match) {
                member_superseeded[i] = 1;
            } else {
                member_superseeded[i] = 0;
            }
        }
    }

    resetList(rel_tags);
    cloneList(rel_tags, &tags);
    resetList(&tags);

    add_z_order(rel_tags, roads);

    return 0;
}
示例#26
0
void CountryList::updateFiltered() {
	resetList();
}
示例#27
0
static unsigned int tagtransform_c_filter_rel_member_tags(
        struct keyval *rel_tags, int member_count,
        struct keyval *member_tags, const char **member_role,
        int * member_superseeded, int * make_boundary, int * make_polygon, int * roads) {
    char *type;
    struct keyval tags, *p, *q, *qq, poly_tags;
    int i, j;
    int first_outerway, contains_tag;

    /* Get the type, if there's no type we don't care */
    type = getItem(rel_tags, "type");
    if (!type)
        return 1;

    initList(&tags);
    initList(&poly_tags);

    /* Clone tags from relation */
    p = rel_tags->next;
    while (p != rel_tags) {
        /* For routes, we convert name to route_name */
        if ((strcmp(type, "route") == 0) && (strcmp(p->key, "name") == 0))
            addItem(&tags, "route_name", p->value, 1);
        else if (strcmp(p->key, "type")) /* drop type= */
            addItem(&tags, p->key, p->value, 1);
        p = p->next;
    }

    if (strcmp(type, "route") == 0) {
        const char *state = getItem(rel_tags, "state");
        const char *netw = getItem(rel_tags, "network");
        int networknr = -1;

        if (state == NULL ) {
            state = "";
        }

        if (netw != NULL ) {
            if (strcmp(netw, "lcn") == 0) {
                networknr = 10;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "lcn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "lcn", "connection", 1);
                } else {
                    addItem(&tags, "lcn", "yes", 1);
                }
            } else if (strcmp(netw, "rcn") == 0) {
                networknr = 11;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "rcn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "rcn", "connection", 1);
                } else {
                    addItem(&tags, "rcn", "yes", 1);
                }
            } else if (strcmp(netw, "ncn") == 0) {
                networknr = 12;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "ncn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "ncn", "connection", 1);
                } else {
                    addItem(&tags, "ncn", "yes", 1);
                }

            } else if (strcmp(netw, "lwn") == 0) {
                networknr = 20;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "lwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "lwn", "connection", 1);
                } else {
                    addItem(&tags, "lwn", "yes", 1);
                }
            } else if (strcmp(netw, "rwn") == 0) {
                networknr = 21;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "rwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "rwn", "connection", 1);
                } else {
                    addItem(&tags, "rwn", "yes", 1);
                }
            } else if (strcmp(netw, "nwn") == 0) {
                networknr = 22;
                if (strcmp(state, "alternate") == 0) {
                    addItem(&tags, "nwn", "alternate", 1);
                } else if (strcmp(state, "connection") == 0) {
                    addItem(&tags, "nwn", "connection", 1);
                } else {
                    addItem(&tags, "nwn", "yes", 1);
                }
            }
        }

        if (getItem(rel_tags, "preferred_color") != NULL ) {
            const char *a = getItem(rel_tags, "preferred_color");
            if (strcmp(a, "0") == 0 || strcmp(a, "1") == 0
                    || strcmp(a, "2") == 0 || strcmp(a, "3") == 0
                    || strcmp(a, "4") == 0) {
                addItem(&tags, "route_pref_color", a, 1);
            } else {
                addItem(&tags, "route_pref_color", "0", 1);
            }
        } else {
            addItem(&tags, "route_pref_color", "0", 1);
        }

        if (getItem(rel_tags, "ref") != NULL ) {
            if (networknr == 10) {
                addItem(&tags, "lcn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 11) {
                addItem(&tags, "rcn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 12) {
                addItem(&tags, "ncn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 20) {
                addItem(&tags, "lwn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 21) {
                addItem(&tags, "rwn_ref", getItem(rel_tags, "ref"), 1);
            } else if (networknr == 22) {
                addItem(&tags, "nwn_ref", getItem(rel_tags, "ref"), 1);
            }
        }
    } else if (strcmp(type, "boundary") == 0) {
        /* Boundaries will get converted into multiple geometries:
         - Linear features will end up in the line and roads tables (useful for admin boundaries)
         - Polygon features also go into the polygon table (useful for national_forests)
         The edges of the polygon also get treated as linear fetaures allowing these to be rendered seperately. */
        *make_boundary = 1;
    } else if (strcmp(type, "multipolygon") == 0
            && getItem(&tags, "boundary")) {
        /* Treat type=multipolygon exactly like type=boundary if it has a boundary tag. */
        *make_boundary = 1;
    } else if (strcmp(type, "multipolygon") == 0) {
        *make_polygon = 1;

        /* Collect a list of polygon-like tags, these are used later to
         identify if an inner rings looks like it should be rendered separately */
        p = tags.next;
        while (p != &tags) {
            if (!strcmp(p->key, "area")) {
                addItem(&poly_tags, p->key, p->value, 1);
            } else {
                for (i = 0; i < exportListCount[OSMTYPE_WAY]; i++) {
                    if (strcmp(exportList[OSMTYPE_WAY][i].name, p->key) == 0) {
                        if (exportList[OSMTYPE_WAY][i].flags & FLAG_POLYGON) {
                            addItem(&poly_tags, p->key, p->value, 1);
                        }
                        break;
                    }
                }
            }
            p = p->next;
        }

        /* Copy the tags from the outer way(s) if the relation is untagged (with
         * respect to tags that influence its polygon nature. Tags like name or fixme should be fine*/
        if (!listHasData(&poly_tags)) {
            first_outerway = 1;
            for (i = 0; i < member_count; i++) {
                if (member_role[i] && !strcmp(member_role[i], "inner"))
                    continue;

                /* insert all tags of the first outerway to the potential list of copied tags. */
                if (first_outerway) {
                    p = member_tags[i].next;
                    while (p != &(member_tags[i])) {
                        addItem(&poly_tags, p->key, p->value, 1);                        
                        p = p->next;
                    }
                } else {
                    /* Check if all of the tags in the list of potential tags are present on this way,
                       otherwise remove from the list of potential tags. Tags need to be present on
                       all outer ways to be copied over to the relation */
                    q = poly_tags.next; 
                    while (q != &poly_tags) {
                        p = getTag(&(member_tags[i]), q->key);
                        if ((p != NULL) && (strcmp(q->value, p->value) == 0)) {
                            q = q->next;
                        } else {
                            /* This tag is not present on all member outer ways, so don't copy it over to relation */
                            qq = q->next;
                            removeTag(q);
                            q = qq;
                        }
                    }
                }
                first_outerway = 0;
            }
            /* Copy the list identified outer way tags over to the relation */
            q = poly_tags.next; 
            while (q != &poly_tags) {
                addItem(&tags, q->key, q->value, 1);                        
                q = q->next;
            }

            /* We need to re-check and only keep polygon tags in the list of polytags */
            q = poly_tags.next; 
            while (q != &poly_tags) {
                contains_tag = 0;
                for (j = 0; j < exportListCount[OSMTYPE_WAY]; j++) {
                    if (strcmp(exportList[OSMTYPE_WAY][j].name, q->key) == 0) {
                        if (exportList[OSMTYPE_WAY][j].flags & FLAG_POLYGON) {
                            contains_tag = 1;
                            break;
                        }
                    }
                }
                if (contains_tag == 0) {
                    qq = q->next;
                    removeTag(q);
                    q = qq;
                } else {
                    q = q->next;
                }
            }
        }
        resetList(&poly_tags);
    } else {
        /* Unknown type, just exit */
        resetList(&tags);
        resetList(&poly_tags);
        return 1;
    }

    if (!listHasData(&tags)) {
        resetList(&tags);
        resetList(&poly_tags);
        return 1;
    }

    /* If we are creating a multipolygon then we
     mark each member so that we can skip them during iterate_ways
     but only if the polygon-tags look the same as the outer ring */
    if (make_polygon) {
        for (i = 0; i < member_count; i++) {
            int match = 1;
            struct keyval *p = member_tags[i].next;
            while (p != &(member_tags[i])) {
                const char *v = getItem(&tags, p->key);
                if (!v || strcmp(v, p->value)) {
                    /* z_order and osm_ are automatically generated tags, so ignore them */
                    if ((strcmp(p->key, "z_order") != 0) && (strcmp(p->key, "osm_user") != 0) && 
                        (strcmp(p->key, "osm_version") != 0) && (strcmp(p->key, "osm_uid") != 0) &&
                        (strcmp(p->key, "osm_changeset")) && (strcmp(p->key, "osm_timestamp") != 0)) {
                        match = 0;
                        break;
                    }
                }
                p = p->next;
            }
            if (match) {
                member_superseeded[i] = 1;
            } else {
                member_superseeded[i] = 0;
            }
        }
    }

    resetList(rel_tags);
    cloneList(rel_tags, &tags);
    resetList(&tags);

    add_z_order(rel_tags, roads);

    return 0;
}
示例#28
0
void GlutMenu::reset() 
{
	resetList();
}
示例#29
0
static void EndElement(const xmlChar *name, struct osmdata_t *osmdata)
{
    if (xmlStrEqual(name, BAD_CAST "node")) {
      if (node_wanted(osmdata, osmdata->node_lat, osmdata->node_lon)) {
	  reproject(&(osmdata->node_lat), &(osmdata->node_lon));
            if( osmdata->action == ACTION_CREATE )
	        osmdata->out->node_add(osmdata->osm_id, osmdata->node_lat, osmdata->node_lon, &(osmdata->tags));
            else if( osmdata->action == ACTION_MODIFY )
	        osmdata->out->node_modify(osmdata->osm_id, osmdata->node_lat, osmdata->node_lon, &(osmdata->tags));
            else if( osmdata->action == ACTION_DELETE )
                osmdata->out->node_delete(osmdata->osm_id);
            else
            {
                fprintf( stderr, "Don't know action for node %d\n", osmdata->osm_id );
                exit_nicely();
            }
        }
        resetList(&(osmdata->tags));
    } else if (xmlStrEqual(name, BAD_CAST "way")) {
        if( osmdata->action == ACTION_CREATE )
	    osmdata->out->way_add(osmdata->osm_id, osmdata->nds, osmdata->nd_count, &(osmdata->tags) );
        else if( osmdata->action == ACTION_MODIFY )
	    osmdata->out->way_modify(osmdata->osm_id, osmdata->nds, osmdata->nd_count, &(osmdata->tags) );
        else if( osmdata->action == ACTION_DELETE )
            osmdata->out->way_delete(osmdata->osm_id);
        else
        {
            fprintf( stderr, "Don't know action for way %d\n", osmdata->osm_id );
            exit_nicely();
        }
        resetList(&(osmdata->tags));
    } else if (xmlStrEqual(name, BAD_CAST "relation")) {
        if( osmdata->action == ACTION_CREATE )
	    osmdata->out->relation_add(osmdata->osm_id, osmdata->members, osmdata->member_count, &(osmdata->tags));
        else if( osmdata->action == ACTION_MODIFY )
	    osmdata->out->relation_modify(osmdata->osm_id, osmdata->members, osmdata->member_count, &(osmdata->tags));
        else if( osmdata->action == ACTION_DELETE )
            osmdata->out->relation_delete(osmdata->osm_id);
        else
        {
            fprintf( stderr, "Don't know action for relation %d\n", osmdata->osm_id );
            exit_nicely();
        }
        resetList(&(osmdata->tags));
        resetMembers(osmdata);
    } else if (xmlStrEqual(name, BAD_CAST "tag")) {
        /* ignore */
    } else if (xmlStrEqual(name, BAD_CAST "nd")) {
        /* ignore */
    } else if (xmlStrEqual(name, BAD_CAST "member")) {
	/* ignore */
    } else if (xmlStrEqual(name, BAD_CAST "osm")) {
        printStatus(osmdata);
        osmdata->filetype = FILETYPE_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "osmChange")) {
        printStatus(osmdata);
        osmdata->filetype = FILETYPE_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "planetdiff")) {
        printStatus(osmdata);
        osmdata->filetype = FILETYPE_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "bound")) {
        /* ignore */
    } else if (xmlStrEqual(name, BAD_CAST "bounds")) {
        /* ignore */
    } else if (xmlStrEqual(name, BAD_CAST "changeset")) {
        /* ignore */
	resetList(&(osmdata->tags)); /* We may have accumulated some tags even if we ignored the changeset */
    } else if (xmlStrEqual(name, BAD_CAST "add")) {
        osmdata->action = ACTION_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "create")) {
        osmdata->action = ACTION_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "modify")) {
        osmdata->action = ACTION_NONE;
    } else if (xmlStrEqual(name, BAD_CAST "delete")) {
        osmdata->action = ACTION_NONE;
    } else {
        fprintf(stderr, "%s: Unknown element name: %s\n", __FUNCTION__, name);
    }
}
void AssetTypeDialog::showDisabled( bool sd )
{
	mShowDisabled->setChecked( sd );
	resetList();
}