Database of world cities (Open Street Map?) [closed] - maps

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I spent my afternoon looking for open databases with the most important cities all over the world,
most of them are premium and costs something like $400, but since I'm working on a open source project I would like to use open data, is there somewhere where I can download the name of important cities?
I found open street map but it is 16gb of things such as nodes relations, but I only need name of cities and coordinates,
thank you very much,
g

This might be more than you're after, but you could use the Overpass API to query all nodes with a key value pair of ["place"="city"].
E.g. go to http://www.overpass-api.de/query_form.html and enter the following:
node
["place"="city"];
out body;
for XML output, or the following for JSON:
[out:json];
node
["place"="city"];
out body;
The output took a minute or so to return to me (it returned 5,000+ nodes), but looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API">
<note>The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history </note>
<meta osm_base="2012-07-22T13:38:02Z"/>
<node id="107775" lat="51.5072759" lon="-0.1276597">
<tag k="capital" v="yes"/>
<tag k="is_in" v="England, United Kingdom, UK, Great Britain, Europe"/>
<tag k="is_in:continent" v="Europe"/>
<tag k="is_in:country" v="United Kingdom"/>
<tag k="name" v="London"/>
<tag k="name:ast" v="Londres"/>
<tag k="name:be" v="Лондан"/>
<tag k="name:br" v="Londrez"/>
<tag k="name:cs" v="Londýn"/>
<tag k="name:cy" v="Llundain"/>
<tag k="name:de" v="London"/>
<tag k="name:el" v="Λονδίνο"/>
<tag k="name:en" v="London"/>
<tag k="name:eo" v="Londono"/>
<tag k="name:es" v="Londres"/>
<tag k="name:fa" v="لندن"/>
<tag k="name:fi" v="Lontoo"/>
<tag k="name:fr" v="Londres"/>
<tag k="name:ga" v="Londain"/>
<tag k="name:gd" v="Lunnainn"/>
<tag k="name:gv" v="Lunnin"/>
<tag k="name:he" v="לונדון"/>
<tag k="name:is" v="Lundúnir"/>
<tag k="name:it" v="Londra"/>
<tag k="name:ja" v="ロンドン"/>
<tag k="name:ku" v="London"/>
<tag k="name:la" v="Londinium"/>
<tag k="name:lv" v="Londona"/>
<tag k="name:nl" v="Londen"/>
<tag k="name:pl" v="Londyn"/>
<tag k="name:pt" v="Londres"/>
<tag k="name:ru" v="Лондон"/>
<tag k="name:sk" v="Londýn"/>
<tag k="name:sr" v="Лондон"/>
<tag k="name:sv" v="London"/>
<tag k="name:uk" v="Лондон"/>
<tag k="name:vi" v="Luân Äôn"/>
<tag k="name:zh" v="伦敦"/>
<tag k="name:zh_pinyin" v="Lúndūn"/>
<tag k="note" v="Centre of London classed as on the charles I moment near trafalgar square"/>
<tag k="place" v="city"/>
<tag k="population" v="7556900"/>
<tag k="rank" v="0"/>
<tag k="wikipedia" v="http://en.wikipedia.org/wiki/London"/>
<tag k="wikipedia:en" v="London"/>
<tag k="wikipedia:fr" v="Londres"/>
</node>
or the following for JSON:
{
"version": 0.6,
"generator": "Overpass API",
"osm3s": {
"timestamp_osm_base": "2012-07-22T14:02:02Z",
"copyright": "The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history"
},
"elements": [
{
"type": "node",
"id": 107775,
"lat": 51.5072759,
"lon": -0.1276597,
"tags": {
"capital": "yes",
"is_in": "England, United Kingdom, UK, Great Britain, Europe",
"is_in:continent": "Europe",
"is_in:country": "United Kingdom",
"name": "London",
"name:ast": "Londres",
"name:be": "Лондан",
"name:br": "Londrez",
"name:cs": "Londýn",
"name:cy": "Llundain",
"name:de": "London",
"name:el": "Λονδίνο",
"name:en": "London",
"name:eo": "Londono",
"name:es": "Londres",
"name:fa": "لندن",
"name:fi": "Lontoo",
"name:fr": "Londres",
"name:ga": "Londain",
"name:gd": "Lunnainn",
"name:gv": "Lunnin",
"name:he": "×œ×•× ×“×•×Ÿ",
"name:is": "Lundúnir",
"name:it": "Londra",
"name:ja": "ロンドン",
"name:ku": "London",
"name:la": "Londinium",
"name:lv": "Londona",
"name:nl": "Londen",
"name:pl": "Londyn",
"name:pt": "Londres",
"name:ru": "Лондон",
"name:sk": "Londýn",
"name:sr": "Лондон",
"name:sv": "London",
"name:uk": "Лондон",
"name:vi": "Luân Äôn",
"name:zh": "伦敦",
"name:zh_pinyin": "Lúndūn",
"note": "Centre of London classed as on the charles I moment near trafalgar square",
"place": "city",
"population": "7556900",
"rank": "0",
"wikipedia": "http://en.wikipedia.org/wiki/London",
"wikipedia:en": "London",
"wikipedia:fr": "Londres"
}
},
More info:
http://wiki.openstreetmap.org/wiki/Tag:place%3Dcity
http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Find_something

Related

How can I sort the post by the score? - React typescript

Im creating 4 posts which have their own score and details from chakraUi. The score is calculated from how many like, comment, and share that post have. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
export type PostProps = {
id: string
name: string
dateTime: string
message: string
likes: number
comments: number
shares: number
avatar: string
media: string
score?: number
}
return (
<Box p="3" minW="sm" maxW="sm" borderWidth="1px" borderRadius="lg" overflow="hidden" fontWeight="semibold">
<Text align="right"> score: {props.score} </Text>
<HStack>
<Avatar size="md" name={props.name} src={props.avatar} />
<VStack spacing="0.5" align={"-moz-initial"}>
<Text align="left">{props.name}</Text>
<Text align="left" color="gray.500" fontWeight="semibold" fontSize="xs">
{props.dateTime}
</Text>
</VStack>
</HStack>
<Container p="1" fontWeight="normal">
{props.message}
<Image src={props.media} alt="" p="1" fit={"cover"} />
</Container>
<HStack spacing="0.5">
<Icon as={AiFillLike} color="#E65300"></Icon>
<Text p="1" fontSize="xs">
{props.likes} {props.comments} {props.shares}
</Text>
<Icon as={AiOutlineShareAlt}></Icon>
</HStack>
</Box>
)
}
return (
<VStack>
<AlgoTester></AlgoTester>
<Post
id="1"
name="Mr.Cat 1"
dateTime={CurrentDate()} /*"23m"*/
message="Hello from the other side!"
// likes=RandomNumber()
likes={RandomNumber()}
comments={RandomNumber()}
shares={RandomNumber()}
avatar="https://upload.wikimedia.org/wikipedia/commons/4/48/RedCat_8727.jpg"
media="https://img.freepik.com/premium-vector/boy-waving-hand-greeting-cute-people-illustration_107355-500.jpg?w=1380"
score={200}
/>
<Post
id="2"
name="Mr.Cat 2"
dateTime={CurrentDate()} /*"1d"*/
message="Seek success, but always be prepared for random cats."
// likes={Math.floor(Math.random() * 1001)}
likes={RandomNumber()}
comments={RandomNumber()}
shares={RandomNumber()}
avatar="https://upload.wikimedia.org/wikipedia/commons/4/48/RedCat_8727.jpg"
media="https://img.freepik.com/premium-vector/smiling-young-man-showing-thumbs-up-illustration-hand-drawn-style_213307-233.jpg?w=1380"
score={100}
/>
<Post
id="3"
name="Mr.Cat 3"
dateTime={CurrentDate()} /*"4h"*/
message="Sometimes I stare at a door or a wall and I wonder what is this reality, why am I alive, and what is this all about?"
// likes={Math.floor(Math.random() * 1001)}
likes={RandomNumber()}
comments={RandomNumber()}
shares={RandomNumber()}
avatar="https://upload.wikimedia.org/wikipedia/commons/4/48/RedCat_8727.jpg"
media="https://img.freepik.com/premium-vector/big-obstacle-concept-illustration_1133-825.jpg?w=1800"
score={800}
/>
<Post
id="4"
name="Mr.Cat 4"
dateTime={CurrentDate()} /*"14m"*/
message="Football is a family of team sports that involve, to varying degrees, kicking a ball to score a goal. Unqualified, the word football normally means the form of football that is the most popular where the word is used. Sports commonly called football include association football (known as soccer in North America and Oceania);
gridiron football (specifically American football or Canadian football); Australian rules football; rugby union and rugby league; and Gaelic football. These various forms of football share to varying extent common origins and are known as football codes."
// likes={Math.floor(Math.random() * 1001)}
likes={RandomNumber()}
comments={RandomNumber()}
shares={RandomNumber()}
avatar="https://upload.wikimedia.org/wikipedia/commons/4/48/RedCat_8727.jpg"
media=""
score={250}
/>
</VStack>
)
How to sort those post by Descending sort(desc)
you can use .sort function of array in js like this. let's assume PostPropsArray is an array that has all the posts.
PostPropsArray.sort((a, b) =>
a.score < b.score ? -1 : 1
);

How to assign dynamic values within codes in react

I am using react-vis-network to create graphs. below is the syntax to use react-vis-network.
const MyNetwork = () => (
<Network>
<Node id='vader' label='Darth Vader' decorator={Decorator} />
<Node id='luke' label='Luke Skywalker' decorator={Decorator} />
<Node id='leia' label='Leia Organa' decorator={Decorator} />
<Edge id='1' from='vader' to='luke' />
<Edge id='1' from='vader' to='leia' />
</Network>
);
i would like assign dynamic values to 'id' and 'label'. I tried below also {n.name}without codes("). both the options are not working.
<Network>
{data.Application.map(n => {
return (
<Node id ="{n.name}" label="{n.name}" />
);
})}
</Network>
can someone advise me on how to pass dynamic values within codes to the variables id and label

Error during application initialization : ClusterSearcher should have a top level dispatch

Application with multiple content and each content with multiple documents is throwing "ClusterSearcher should have a top level dispatch." when deployed on multi node cluster with multiple content nodes. The same is working on a single node cluster with a single content node.
Using [Vespa version: ] 7.51.13
com.yahoo.container.di.componentgraph.core.ComponentNode$ComponentConstructorException: Error constructing 'com.yahoo.prelude.cluster.ClusterSearcher in acme'
Caused by: java.lang.IllegalStateException: ClusterSearcher should have a top level dispatch.
================= services.xml ==============
<?xml version="1.0" encoding="utf-8" ?>
<admin version="2.0">
<adminserver hostalias="admin0"/>
<configservers>
<configserver hostalias="admin0"/>
</configservers>
</admin>
<container id="container" version="1.0">
<config name="search.config.qr-start">
<jvm>
<heapSizeAsPercentageOfPhysicalMemory>50</heapSizeAsPercentageOfPhysicalMemory>
</jvm>
</config>
<document-api />
<http>
<server id="stateless1" port="8080">
</server>
</http>
<search>
<chain id="default" inherits="vespa">
<searcher id="com.acme.search.CatalogSearcher" bundle="sth-search">
<config name="com.acme.search.Searcher">
<redirectsFile>redirects.txt</redirectsFile>
<autoCorrectAPI>https://apps02.acme.com:9815/search/</autoCorrectAPI>
<connectionTimeout>250</connectionTimeout>
<connectionRequestTimeout>250</connectionRequestTimeout>
<socketTimeout>250</socketTimeout>
</config>
</searcher>
</chain>
</search>
<nodes jvmargs="-verbose:gc">
<node hostalias="stateless0"/>
<node hostalias="stateless1"/>
</nodes>
</container>
<content id="sth" version="1.0">
<redundancy>2</redundancy>
<documents>
<document type="sth" mode="index" />
</documents>
<nodes>
<node hostalias="content0" distribution-key="0"/>
<node hostalias="content1" distribution-key="1"/>
</nodes>
</content>
<content id="thesaurus" version="1.0">
<redundancy>2</redundancy>
<documents>
<document type="thesaurus" mode="index"/>
</documents>
<nodes>
<node hostalias="content0" distribution-key="0"/>
<node hostalias="content1" distribution-key="1"/>
</nodes>
</content>
<content id="acme" version="1.0">
<redundancy>2</redundancy>
<documents>
<document type="vc_products" mode="index" />
<document type="vc_thesaurus" mode="index"/>
</documents>
<nodes>
<node hostalias="content0" distribution-key="0"/>
<node hostalias="content1" distribution-key="1"/>
</nodes>
</content>
From comments, you get this not when you actually deploy on multiple nodes but when you try to instantiate a mock Application instance in a unit test, as in Application.fromApplicationPackage(...).
The reason for this is that Application is not able to fully mock a full application, only the stateless container parts. The ClusterSearcher which is instantiated in this setup complains that it can't see any real content clusters downstream (which is correct), it does not know it has been created in a mocked setup.
For this reason you need to create special services.xmls for unit tests as in general the one you use in production will give problems like this. Using Application works well for testing specific functionality of a set of components but not for unit testing your true production application.
We would like to improve this by mocking component clusters inside application but nobody's working on it at the moment. if you want to have a go at it the code is in
https://github.com/vespa-engine/vespa/tree/master/application

Display nested data using `admin-on-rest`

I have data in the following format -
{
"categories": [
{
"id": "1",
"code": "TESTCODE001",
"name": "TESTCODE001",
"subcategories": [
{
"id": "11",
"code": "TESTCODE0002",
"name": "TESTCODE0002",
"subcategories": []
}
]
}
I am not able to display subcategories. I have tried using ReferenceArrayField but I am not able to use it, as categories and subcategories are fetched from the same API. Also tried using custom component to display subcategories, this is also not possible as it shows the edit form when I click on subcategories.
The code I have written-
categories.js
export const CategoryList = (props) => (
<List title="All categories" {...props} >
<Datagrid>
<TextField source="code" />
<TextField source="name" />
<TextField source="id" />
<LinkToRelatedSubcategories/>
<EditButton />
</Datagrid>
</List>
);
LinkToRelatedSubcategories.js
const LinkToRelatedSubcategories = ({ record, translate }) => (
<FlatButton
primary
label='Subcategories'
containerElement={<Link params={{ testvalue: "hello" }}
to={{
pathname: '/category/categoryId',
}}
/>}
/>
);
Any help will be highly appreciated.
this is also not possible as it shows the edit form when I click on subcategories.
For the show page, you can use: /category/categoryId/show
Maybe you can use react-admin instead of admin-on-rest. Its the new version, now in release candidate mode. It has https://marmelab.com/react-admin/Fields.html#arrayfield and https://marmelab.com/react-admin/Inputs.html#arrayinput

Updating multiple XML columns using single update in SQL Server

I would like to update a table_A with new values for (AcresDist1, txtAcresDist1, txtAcresDist1Total) XML columns from a second table_B.
The column P_XML is of XML type. I know how to update a single column at once, but I would like to know how to update multiple columns in the XML using a single update statement. Thanks
SQL code:
UPDATE S
SET
P_XML.modify( N'replace value of (/FormValue/f1152_F1/Field[(id/text())[1]="AcresDist1"]/value/text())[1] with sql:column(''T.AcresDist1'')' )
, P_XML.modify( N'replace value of (/FormValue/f1152_F1/Field[(id/text())[1]="txtAcresDist1"]/value/text())[1] with sql:column(''T.txtAcresDist'')' )
, P_XML.modify( N'replace value of (/FormValue/f1152_F1/Field[(id/text())[1]="txtAcresDist1Total"]/value/text())[1] with sql:column(''T.txtAcresDist1Total'')' )
FROM
Table_A AS S
INNER JOIN
Table_B AS T ON s.P_NO = t.P_Number
AND s.FAC_RID = t.Fac_RID;
Here is the sample xml as requested. Thank you.
<FormValue>
<f1152>
<field>
<id>f1152_MainForm</id>
<value />
<tag />
<visible>true</visible>
<history>|09/28/2017 10:50:26 AM||</history>
<description />
<comment />
</field>
<field>
<id>txt_rdoCoverage</id>
<value>Development</value>
<tag />
<visible>false</visible>
<history>|09/28/2017 10:50:26 AM||</history>
<description />
<comment />
</field>
</f1152>
<f1152_F1>
<field>
<id>txtAcresDist1</id>
<value>1.2</value>
<tag />
<visible>false</visible>
<history>|09/28/2017 3:08:14 AM||</history>
<description />
<comment />
</field>
<field>
<id>txtAcresDist1Total</id>
<value>200</value>
<tag />
<visible>false</visible>
<history>|09/28/2017 3:08:14 AM||</history>
<description />
<comment />
</field>
</f1152_F1>

Resources