Exemplo n.º 1
0
    // function a(e, r, n)
    // {
    //  _.each(e, function(e) {
    //      if (r) {
    //          if (n && e.font_size < 5) return;
    //          if (!n && e.font_size > 5) return
    //      }
    //      var a = new o;
    //      vec2.copy(a.coord, e.coord),
    //      a.coord[2] *= 2,
    //      a.name = e.name,
    //      a.font_size = e.font_size,
    //      r ? a.name = a.name.toUpperCase() : a.font_size = 3,
    //      e.iso2 && (a.iso2 = e.iso2),
    //      t.labels.push(a)
    //  })
    void CountryToLableData(label_country_data e, bool r, bool n)
    {
        if (r)
        {
            if (n && e.font_size < 5)
            {
                return;
            }
            if (!n && e.font_size > 5)
            {
                return;
            }
        }
        label_data ld = new label_data();

        ld.coord     = e.coord;
        ld.coord[2] *= 2;
        ld.name      = e.name;
        ld.font_size = e.font_size;
        ld.pick_uid  = e.pick_uid;
        if (r)
        {
            ld.name = ld.name.ToUpper();
        }
        else
        {
            ld.font_size = 3;
        }
        ld.iso2 = e.iso2;

        labels_data_list.Add(ld);
    }
Exemplo n.º 2
0
    public void build_labels()
    {
        string strLoadData = string.Empty;

        Object    objLoad = Resources.Load("Datas/labels");
        TextAsset txtAst  = objLoad as TextAsset;

        if (null == txtAst)
        {
            Debug.LogError("Error Load : " + "labels_json");
            return;
        }
        else
        {
            strLoadData = txtAst.text;
        }

        bool      ok = false;
        Hashtable hashLabelJson;

        hashLabelJson = (Hashtable)JSON.JsonDecode(strLoadData, ref ok);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////
        //         function n() {
        //                  var e = window.lang;
        //                  _.each(r.countries, function(t) {
        //                      var r = 'MAP_COUNTRY_' + t.iso3.toUpperCase();
        //                      t.name = e.getText(r)
        //                  }),
        //                  _.each(r.cities, function(t) {
        //                      var r = 'MAP_CITY_' + t.code.toUpperCase();
        //                      t.name = e.getText(r)
        //                  })
        //              }
        //////////////////读取label数据,并重构county,city列表
        List <label_country_data> countries_label_data = new List <label_country_data>();
        ArrayList alCountries = (ArrayList)hashLabelJson["countries"];

        foreach (Hashtable htCountry in alCountries)
        {
            label_country_data cdata = new label_country_data();
            ArrayList          coord = (ArrayList)htCountry["coord"];
            cdata.coord.Set((float)(double)coord[0], (float)(double)coord[1]);
            cdata.iso2 = (string)htCountry["iso2"];
            cdata.iso3 = (string)htCountry["iso3"];
            //Hashtable name = (Hashtable)htCountry["name"];
            cdata.font_size = (float)(double)htCountry["font_size"];
            cdata.name      = Map.db["MAP_COUNTRY_" + cdata.iso3.ToUpper()];
            countries_label_data.Add(cdata);
        }

        List <city_data> cities_label_data = new List <city_data>();
        ArrayList        alCities          = (ArrayList)hashLabelJson["cities"];

        foreach (Hashtable htCity in alCities)
        {
            city_data cdata = new city_data();
            ArrayList coord = (ArrayList)htCity["coord"];
            cdata.coord.Set((float)(double)coord[0], (float)(double)coord[1]);
            cdata.code = (string)htCity["code"];
            //Hashtable name = (Hashtable)htCity["name"];
            cdata.font_size = (float)(double)htCity["font_size"];
            cdata.name      = Map.db["MAP_CITY_" + cdata.code.ToUpper()];
            cities_label_data.Add(cdata);
        }

        foreach (label_country_data cdata in countries_label_data) // a(r.countries, !0, !0),
        {
            CountryToLableData(cdata, true, true);
        }

        country_count = labels_data_list.Count;        // t.country_count = t.labels.length,

        foreach (city_data cdata in cities_label_data) // a(r.cities, !1, !1),
        {
            CityToLableData(cdata, false, false);
        }

        foreach (label_country_data cdata in countries_label_data)// a(r.countries, !0, !1),
        {
            CountryToLableData(cdata, true, false);
        }

        city_data tmpcd = new city_data();

        foreach (country_data cd in ChinaProvinceCity.Instance.cdd.china_provinces)
        {
            if (cd.center_location == Vector2.zero)
            {
                continue;
            }

            tmpcd.coord    = cd.center_location;
            tmpcd.name     = cd.name;
            tmpcd.pick_uid = cd.uid;
            if (cd.byType == 0)
            {
                tmpcd.font_size = 4;
            }
            else if (cd.byType == 3)
            {
                tmpcd.font_size = 3;
            }
            CityToLableData(tmpcd, false, false);
            AddAdjustHelper(tmpcd);
        }

        if (bShowChinaCityLabel)
        {
            foreach (country_data cd in ChinaProvinceCity.Instance.cdd.china_cities)
            {
                if (cd.center_location == Vector2.zero)
                {
                    continue;
                }

                tmpcd.coord     = cd.center_location;
                tmpcd.name      = cd.name;
                tmpcd.pick_uid  = cd.uid;
                tmpcd.font_size = 1.5f;
                CityToLableData(tmpcd, false, false);
                AddAdjustHelper(tmpcd);
            }
        }

        city_count = labels_data_list.Count - country_count;//t.city_count = t.labels.length - t.country_count;



        // e.render_labels('en'),
        // e.project_labels('ecef')
    }