Giter VIP home page Giter VIP logo

magicodes.districts's Introduction

Magicodes.Districts

  行政区域信息核心库。以便于获取最新的行政区域数据用于自动更新业务数据库等。
  官方网址:http://xin-lai.com
  开源库地址:https://github.com/xin-lai
  博客地址:http://www.cnblogs.com/codelove/
  交流QQ群:85318032
  小店地址:https://shop113059108.taobao.com/
  最新框架(完全支持.NET Core):https://gitee.com/xl_wenqiang/Magicodes.Admin.Core
  已更新为.NET标准库,支持.NET Core
  已编写单元测试,可以自行配置。

  目前只支持通过高德API获取。后续再对接其他服务商。

高德接口配置

	请先申请高德的开发者Key。
    var districtsProvider = new AmapDistrictsProvider(settings.ApiKey);

获取**省市区街道信息

    var result = await DistrictsProvider.GetDistricts();

	具体见单元测试:

	[Fact]
    public async Task GetDistricts_TestsAsync()
    {
        var result = await DistrictsProvider.GetDistricts();
        result.ShouldNotBeNull();

        //一级行政区(省级行政区):34个(23个省、5个自治区、4个直辖市、2个特别行政区) ...**
        result[0].Children.Count.ShouldBeGreaterThanOrEqualTo(34);

        //二级行政区(地级行政区):334个(294个地级市、7个地区、30个自治州、3个盟)
        result[0].Children.Sum(p => p.Children.Count).ShouldBeGreaterThanOrEqualTo(334);

    }

	[Fact]
    public async Task GetDistrictsByKeywords_TestsAsync()
    {
        var result = await DistrictsProvider.GetDistricts("湖南");
        result.ShouldNotBeNull();

        //截止2017年9月12日,湖南省共计划分为14个地区(13地级市和1自治州),122个县级行政区包括35个市辖区、17个县级市、63个县和7个自治县
        result[0].Children.Count.ShouldBeGreaterThanOrEqualTo(14);
        result[0].Children.Sum(p => p.Children.Count).ShouldBeGreaterThanOrEqualTo(122);

    }

magicodes.districts's People

Contributors

codelove1314 avatar xin-lai avatar

Watchers

James Cloos avatar  avatar

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.