Giter Site home page Giter Site logo

muratgozel / turkey-neighbourhoods Goto Github PK

View Code? Open in Web Editor NEW
52.0 4.0 9.0 18.04 MB

Always up to date names of cities, districts and neighbourhoods of Turkey + city distances. / Her zaman güncel, Türkiye şehir, posta kodu, plaka kodu, ilçe ve mahalle listesi + şehirlerarası mesafeler.

License: MIT License

JavaScript 35.40% TypeScript 64.60%
turkey turkey-post-codes turkey-cities turkey-districts turkey-neighbourhoods turkiye-il-ilce-listesi turkiye-mahalle-listesi

turkey-neighbourhoods's Introduction

turkey-neighbourhoods

Always up to date names of cities, districts and neighbourhoods of Turkey + city distances.

**In Turkish: ** Her zaman güncel, Türkiye şehir, posta kodu, plaka kodu, ilçe ve mahalle listesi + şehirlerarası mesafeler.

Install

npm i turkey-neighbourhoods

or inject with script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/turkey-neighbourhoods@4/dist/index.js"></script>

Usage

The package contains large amount of data which is not suitable for browser environment. Benefit from tree-shaking might work if you are interested in small chunks of it.

There are no states in Turkey. The data structured as cities (city code and name), districts (name) and neighbourhoods (name). City codes are two digit text and they also known as plate number.

There are couple of methods to interact with the data:

import {
    isCityCode,
    isCityName,
    isPostalCode,
    getCityNames,
    getCityCodes,
    getCities,
    getPostalCodes,
    getDistrictsByCityCode,
    getDistrictsOfEachCity,
    getDistrictsAndNeighbourhoodsByCityCode,
    getDistrictsAndNeighbourhoodsOfEachCity,
    getNeighbourhoodsByCityCodeAndDistrict,
    findDistance,
    findClosestCities
} from 'turkey-neighbourhoods'

isCityCode('01') // true
isCityCode('82') // false
isCityCode(1) // false

isCityName('İstanbul') // true
isCityName('istanbul') // false, because city names are always title cased

getCityCodes() // ["01", "02", ... "67"] sorted by name, 81 in total
getCityNames() // ["Adana", "Adıyaman", ... "Zonguldak"]
getCities() // [{code: "01", name: "Adana"}, ... {code: "67", name: "Zonguldak"}]

getPostalCodes() // ["01720", ... "67100"]
isPostalCode('01720') // true

getDistrictsByCityCode('16') // ["Büyükorhan", "Gemlik", "Gürsu", ... "Yıldırım"]
getDistrictsOfEachCity() // {"16": ["Nilüfer", ...]}
getDistrictsAndNeighbourhoodsByCityCode('16') // {"Büyükorhan": ["Akçasaz Mah", "Aktaş Mah", ...], "Gemlik": ["Adliye Mah", ...], ...}
getDistrictsAndNeighbourhoodsOfEachCity() // {"16": {"Gemlik": ["Adliye Mah", ...] ...} ...}
getNeighbourhoodsByCityCodeAndDistrict("16", "Nilüfer") // ["Alaaddinbey Mah", "Ataevler Mah" ...]

// find distance between two cities in kilometers based on the roads
findDistance('41', '16') // 131

// find closest cities to a particular city, 200 km far at most and limit results to three
findClosestCities('16', 200, 3) // [{code: '77', distance: 69}, ...]

Have a look at the tests, types and source for more info.

Keeping Data Up To Date

Data updates published regularly as minor releases so check regularly for updates. The data source updates it every month.

Contributing

If you're interested in contributing, read the CONTRIBUTING.md first, please.


Version management of this repository done by releaser 🚀


Thanks for watching 🐬

Support me on Patreon

turkey-neighbourhoods's People

Contributors

muratgozel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

turkey-neighbourhoods's Issues

Fix a typo in Sultangazi/Istanbul neighbourhoods

For the following neighborhoods of Sultangazi/Istanbul, one of them is written with "b" and the other one is written with "p":

  • Eski Habipler Mah
  • Habibler Mah
    image

If you take a look at Sultangazi Belediye website, you see that both of their names are with b.

Also, we were doing some data migrations on our website, and we had a bug because of this, when we looked at the addresses in that neighborhood, we understood that users are usually writing it as "Eski Habibler Mah" in their address text. so I guess the correct version is "b".

Thanks for maintaining this list, it's very useful for us.

ESM not-supported error on v3

I'm trying to use turkey-neighbourhoods@v3 in a nx monorepo with the default tsconfig

> nx run my-app-name:serve:development

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /path-to-repo/node_modules/.pnpm/[email protected]/node_modules/turkey-neighbourhoods/dist/turkey-neighbourhoods.cjs.js not supported.
turkey-neighbourhoods.cjs.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename turkey-neighbourhoods.cjs.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /path-to-repo/node_modules/.pnpm/[email protected]/node_modules/turkey-neighbourhoods/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Module._load (/path-to-repo/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:6252:18)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Array.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:6211:33)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5734:28)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5408:48)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5390:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:3796:30)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:3719:28)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:1530:31)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:1513:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:412:20)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Array.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:14:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at /path-to-repo/dist/apps/my-app-name/main.js:6475:37
    at Object.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:6480:12)
    at Module._load (/path-to-repo/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:10:31) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.15.0

İlçenin mahalleleri string[] dönmüyor.

getCityDistrictNeighbourhoods methodunun 2.ci parametresi düzgün çalışmıyor. Tüm ilçelerin mahallelerini dönüyor.

test('validate return typeof function', () => {
const result = getCityDistrictNeighbourhoods('34', "Sarıyer")
expect(Array.isArray(result)).toBe(true)
})

böyle bir test yazıp pr açıcaktım ama pr kapalı

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.