mousebird-consulting-inc / WhirlyGlobe

WhirlyGlobe Development
Other
828 stars 254 forks source link

My globe preview is below (Android) #1415

Closed zhufeixiang closed 3 years ago

zhufeixiang commented 3 years ago

the AAR version is 3.3

here is my code :

open class HelloGlobeFragment : GlobeMapFragment() {
    override fun chooseDisplayType(): MapDisplayType {
        return MapDisplayType.Map
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        inState: Bundle?
    ): View? {
        super.onCreateView(inflater, container, inState)

        // Do app specific setup logic.
        return baseControl.contentView
    }

    var particleThread: LayerThread? = null
    var particleAdapter: MaplyStarModel? = null

    var shader: Shader? = null
    var varTarget: VariableTarget? = null
    override fun controlHasStarted() {

        //星空顶
        globeControl.addPostSurfaceRunnable(Runnable {
            globeControl.setClearColor(Color.BLACK)
            particleThread = globeControl.makeLayerThread(false)
            try {
                particleAdapter = MaplyStarModel(
                    "starcatalog_orig.txt", "star_background.png",
                    activity
                )
                particleAdapter!!.addToViewc(globeControl, ThreadMode.ThreadCurrent)
            } catch (e: IOException) {
                e.printStackTrace()
            }
        })

        val cacheDirName = "carto_light"
        val cacheDir = File(activity?.cacheDir, cacheDirName)
        cacheDir.mkdir()

        // Where we're getting the tile from
        var tileInfo = RemoteTileInfoNew("http://t7.tianditu.gov.cn/img_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=img&style=default&tilematrixset=w&format=tiles&tilematrix={z}&tilerow={x}&tilecol={y}&tk=21acecb607e8c575b1668c600606da16", 0, 6)
        tileInfo.cacheDir = cacheDir

        // Sampling params define how the globe is broken up, including the depth
        var params = SamplingParams()
        params.coordSystem = SphericalMercatorCoordSystem()
        params.coverPoles = true
        params.edgeMatching = true
        params.singleLevel = true
        params.minZoom = 0
        params.maxZoom = 6

        var loader = QuadImageLoader(params,tileInfo,globeControl)

        val sources = RemoteTileInfoNew(
            "http://t2.tianditu.gov.cn/cva_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=cva&style=default&tilematrixset=w&format=tiles&tilematrix={z}&tilerow={x}&tilecol={y}&tk=21acecb607e8c575b1668c600606da16",
            0,
            6
        )
        // Set up the globe parameters
        val params2 = SamplingParams()
        params2.coordSystem = SphericalMercatorCoordSystem()
        params2.coverPoles = true
        params2.edgeMatching = true
        params2.minZoom = 0
        params2.maxZoom = 6
        val loader2 = QuadImageLoader(params, sources, globeControl)

        val sources2 = RemoteTileInfoNew(
            "http://t2.tianditu.gov.cn/ibo_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=ibo&style=default&tilematrixset=w&format=tiles&tilematrix={z}&tilerow={x}&tilecol={y}&tk=21acecb607e8c575b1668c600606da16",
            0,
            6
        )
        // Set up the globe parameters
        val params3 = SamplingParams()
        params3.coordSystem = SphericalMercatorCoordSystem()
        params3.coverPoles = true
        params3.edgeMatching = true
        params3.minZoom = 0
        params3.maxZoom = 6
        val loader3 = QuadImageLoader(params3, sources2, globeControl)

    }

    }

could you help me ?

mousebird commented 3 years ago

What's your question?

zhufeixiang commented 3 years ago

What's your question?

The picture is fragmented, not complete

mousebird commented 3 years ago

Something to do with the tile source I'd imagine. Try setting flipY to true or false and see if that helps. I believe it's on the Quad Loader or the SamplingParams.