Select to view content in your preferred language

Optimization of GeoJSON layer

558
2
07-17-2023 01:59 AM
kawishabbas
Occasional Contributor

Hello community,

I hope all of you are fine and doing best in your domain. I need a suggestion regarding the mentioned subject.
I have a PostgreSQL database with the PostGIS spatial extension to store spatial records. Additionally, I am using GeoServer as a mapping server, which directly connects to the database and retrieves the data in GeoJSON format. On the client-side, I am utilizing the ArcGIS API. However, I am facing performance issues as the map takes a significant amount of time to render the 100k records. Compounding the issue, I have a complex symbology setup, which I describe in code snippet.

With complex expression, I am facing challenges in reducing the response time of the GeoJSONLayer. One possible solution is to use the CQL_FILTER method provided by GeoServer, which allows me to retrieve only the specified query records. However, the limitation of this approach is that I cannot update the CQL_FILTER (Geojson URL) in an existing layer view without creating another instance of the GeoJSONLayer. This can be time-consuming and inefficient when working with a large dataset like the 100k records I have.

Another approach I have tried is using the definitionExpression method of the GeoJSONLayer, but it fetches all the records from the server before applying the filter, resulting in longer load times for the 100k records

Please provide guidance on any possible solutions to resolve this issue. I am looking for ways to optimize the response time of the GeoJSONLayer.I would appreciate any suggestions on how to address this challenge.

 

Thanks & Regards,

Kawish

 

const { customer } = this.context.view;
    const name = "$feature.alarmstate";
    const cat = "$feature.category";
    const week = "$feature.lastdowntime";
    const ticketStatus = "$feature.ticketstatus";

    let valueExpression = `When( 

                ${name} == 0 && ${cat} == 'VIP', 'zero',
    
                ${name} == 1 && ${cat} == 'VIP', 'one',
    
                ${name} == 2 && ${cat} == 'VIP' && ${week} >= '${complete_date}', 'two',
    
                ${name} == 2 && ${cat} == 'VIP' && ${week} <= '${complete_date}', 'two_1',
    
                ${name} == 3 && ${cat} == 'VIP', 'three',
        
                ${name} == 4 && ${cat} == 'VIP', 'four',
                
                ${name} == 2 && ${cat} != 'VIP' && ${week} <= '${complete_date}' && ${ticketStatus} != 'In-process', 'two_1_not_vip',
                ${name} == 2 && ${cat} != 'VIP' && ${week} <= '${complete_date}' && ${ticketStatus} == 'In-process', 'c-two_1',
                
                ${name} == 2 && ${cat} != 'VIP' && ${week} >= '${complete_date}' && ${ticketStatus} != 'In-process', 2,
                ${name} == 2 && ${cat} != 'VIP' && ${week} >= '${complete_date}' && ${ticketStatus} == 'In-process', 'c-two',
               
                
                ${name} == 0 && ${cat} != 'VIP' && ${ticketStatus} != 'In-process', 0,
                ${name} == 0 && ${cat} != 'VIP' && ${ticketStatus} == 'In-process', 'c-0',
    
                ${name} == 1 && ${cat} != 'VIP' && ${ticketStatus} != 'In-process', 1,
                ${name} == 1 && ${cat} != 'VIP' && ${ticketStatus} == 'In-process', 'c-1',
    
                ${name} == 3 && ${cat} != 'VIP'  && ${ticketStatus} != 'In-process', 3,
                ${name} == 3 && ${cat} != 'VIP'  && ${ticketStatus} == 'In-process', 'c-3',
    
                ${name} == 4 && ${cat} != 'VIP' && ${ticketStatus} != 'In-process', 4,
                ${name} == 4 && ${cat} != 'VIP' && ${ticketStatus} == 'In-process', 'c-4',
                5
                )`;

 

 

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

Are you using the customParameters object to specify your CQL_FILTER value?  My understanding is that you should be able to update this value without having to create a whole new layer object.

0 Kudos
UndralBatsukh
Esri Regular Contributor

As @JoelBennett mentioned above you can use the GeoJSONLayer.customParameters if the CQL_FILTER is part of the url query. If it is then you can set the customParameters after the GeoJSONLayer is initialized. You also have to call the GeoJSONLayer.refresh() method once you set the customParameters.

Please take a look at this sample: https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson-refresh/

 

 

0 Kudos