@@ -847,104 +847,3 @@ pc_patch_deserialize(const SERIALIZED_PATCH *serpatch, const PCSCHEMA *schema)
847
847
pcerror ("%s: unsupported compression type" , __func__ );
848
848
return NULL ;
849
849
}
850
-
851
-
852
- static uint8_t *
853
- pc_patch_wkb_set_double (uint8_t * wkb , double d )
854
- {
855
- memcpy (wkb , & d , 8 );
856
- wkb += 8 ;
857
- return wkb ;
858
- }
859
-
860
- static uint8_t *
861
- pc_patch_wkb_set_int32 (uint8_t * wkb , uint32_t i )
862
- {
863
- memcpy (wkb , & i , 4 );
864
- wkb += 4 ;
865
- return wkb ;
866
- }
867
-
868
- static uint8_t *
869
- pc_patch_wkb_set_char (uint8_t * wkb , char c )
870
- {
871
- memcpy (wkb , & c , 1 );
872
- wkb += 1 ;
873
- return wkb ;
874
- }
875
-
876
- /* 0 = xdr | big endian */
877
- /* 1 = ndr | little endian */
878
- static char
879
- machine_endian (void )
880
- {
881
- static int check_int = 1 ; /* dont modify this!!! */
882
- return * ((char * ) & check_int );
883
- }
884
-
885
- uint8_t *
886
- pc_patch_to_geometry_wkb_envelope (const SERIALIZED_PATCH * pa , const PCSCHEMA * schema , size_t * wkbsize )
887
- {
888
- static uint32_t srid_mask = 0x20000000 ;
889
- static uint32_t nrings = 1 ;
890
- static uint32_t npoints = 5 ;
891
- uint32_t wkbtype = 3 ; /* WKB POLYGON */
892
- uint8_t * wkb , * ptr ;
893
- int has_srid = false;
894
- size_t size = 1 + 4 + 4 + 4 + 2 * npoints * 8 ; /* endian + type + nrings + npoints + 5 dbl pts */
895
-
896
- /* Bounds! */
897
- double xmin = pa -> bounds .xmin ;
898
- double ymin = pa -> bounds .ymin ;
899
- double xmax = pa -> bounds .xmax ;
900
- double ymax = pa -> bounds .ymax ;
901
-
902
- /* Make sure they're slightly bigger than a point */
903
- if ( xmin == xmax ) xmax += xmax * 0.0000001 ;
904
- if ( ymin == ymax ) ymax += ymax * 0.0000001 ;
905
-
906
- if ( schema -> srid > 0 )
907
- {
908
- has_srid = true;
909
- wkbtype |= srid_mask ;
910
- size += 4 ;
911
- }
912
-
913
- wkb = palloc (size );
914
- ptr = wkb ;
915
-
916
- ptr = pc_patch_wkb_set_char (ptr , machine_endian ()); /* Endian flag */
917
-
918
- ptr = pc_patch_wkb_set_int32 (ptr , wkbtype ); /* TYPE = Polygon */
919
-
920
- if ( has_srid )
921
- {
922
- ptr = pc_patch_wkb_set_int32 (ptr , schema -> srid ); /* SRID */
923
- }
924
-
925
- ptr = pc_patch_wkb_set_int32 (ptr , nrings ); /* NRINGS = 1 */
926
- ptr = pc_patch_wkb_set_int32 (ptr , npoints ); /* NPOINTS = 5 */
927
-
928
- /* Point 0 */
929
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .xmin );
930
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .ymin );
931
-
932
- /* Point 1 */
933
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .xmin );
934
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .ymax );
935
-
936
- /* Point 2 */
937
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .xmax );
938
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .ymax );
939
-
940
- /* Point 3 */
941
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .xmax );
942
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .ymin );
943
-
944
- /* Point 4 */
945
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .xmin );
946
- ptr = pc_patch_wkb_set_double (ptr , pa -> bounds .ymin );
947
-
948
- if ( wkbsize ) * wkbsize = size ;
949
- return wkb ;
950
- }
0 commit comments