Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken promise chain #61

Open
wants to merge 107 commits into
base: dev
Choose a base branch
from

Conversation

matteopic
Copy link
Contributor

@matteopic matteopic commented Sep 10, 2023

This fixes #60.

The message reported happens because the Svx3dLoader parses the .3d files in two steps; first calling method parse(), then calling parse2().

Survey class performs the following check after the model has been loaded:

if ( surveyData.limits.isEmpty() ) throw new Error( 'Empty survey or region of survey' );

If the model has an init value equal to epsg:27700 the loading works correctly because there is a piece of sync code that handle it, but if it is different then a fetch to https://epsg.io site starts.

...
switch ( init ) {
    case 'epsg:27700' :
sourceCRS = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs';
break;

default:
    code = init.match( /(epsg|esri):([0-9]+)/ );
    if ( code !== null ) {
            console.log( `looking up CRS code EPSG: ${code[ 2 ]}` );
            return fetch( `https://epsg.io/${code[ 2 ]}.proj4` )
...

The absence of return inside the Svx3dLoader.load cause the promise chain to break and when the async call to https://epsg.io begin, the execution continues even though the model has not fully loaded.

load ( loadingContext, progress, surveyDataCollector ) {
	return super.load( 'arraybuffer', loadingContext, progress ).then( results => {
                    // Promise chain breaks here
		this.parse( surveyDataCollector, results.data, results.metadata, loadingContext.section, progress );
	} );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Empty survey or region of survey
1 participant